From 3ff0cd546ad8990a577b9f82cf3f73be85ed5555 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 22 Sep 2023 22:18:55 +0300
Subject: SL-20188 Size of friend list affects time to open Preferences floater

Don't check every file when it's enough to know if there are any.
---
 indra/newview/llfloaterpreference.cpp |  4 +---
 indra/newview/lllogchat.cpp           | 21 +++++++++++++++++++++
 indra/newview/lllogchat.h             |  1 +
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 9ea49e935f..e48f989c52 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -471,9 +471,7 @@ BOOL LLFloaterPreference::postBuild()
 
 void LLFloaterPreference::updateDeleteTranscriptsButton()
 {
-	std::vector<std::string> list_of_transcriptions_file_names;
-	LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
-	getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
+	getChild<LLButton>("delete_transcripts")->setEnabled(LLLogChat::transcriptFilesExist());
 }
 
 void LLFloaterPreference::onDoNotDisturbResponseChanged()
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index ba82ff0b0f..1592afc66c 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -651,6 +651,27 @@ std::string LLLogChat::oldLogFileName(std::string filename)
 	return scanResult;
 }
 
+bool LLLogChat::transcriptFilesExist()
+{
+    std::string pattern = "*." + LL_TRANSCRIPT_FILE_EXTENSION;
+    // get Users log directory
+    std::string dirname = gDirUtilp->getPerAccountChatLogsDir();
+
+    // add final OS dependent delimiter
+    dirname += gDirUtilp->getDirDelimiter();
+
+    LLDirIterator iter(dirname, pattern);
+    std::string filename;
+    while (iter.next(filename))
+    {
+        std::string fullname = gDirUtilp->add(dirname, filename);
+        if (isTranscriptFileFound(fullname))
+        {
+            return true;
+        }
+    }
+    return false;
+}
 // static
 void LLLogChat::findTranscriptFiles(std::string pattern, std::vector<std::string>& list_of_transcriptions)
 {
diff --git a/indra/newview/lllogchat.h b/indra/newview/lllogchat.h
index 5dce8ab1d2..9e2e060de2 100644
--- a/indra/newview/lllogchat.h
+++ b/indra/newview/lllogchat.h
@@ -103,6 +103,7 @@ public:
 				const std::string& from,
 				const LLUUID& from_id,
 				const std::string& line);
+    static bool transcriptFilesExist();
 	static void findTranscriptFiles(std::string pattern, std::vector<std::string>& list_of_transcriptions);
 	static void getListOfTranscriptFiles(std::vector<std::string>& list);
 	static void getListOfTranscriptBackupFiles(std::vector<std::string>& list_of_transcriptions);
-- 
cgit v1.2.3