From 92a11312901ca04bb68261bc9782ee62b725a956 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 8 Mar 2024 10:22:51 -0500
Subject: [PATCH] Probs fix nearby chat

---
 indra/newview/llfloaterimnearbychat.cpp | 29 +++++++++++++++++++++++++
 indra/newview/llfloaterimnearbychat.h   |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index b2a9a0e99ff..d543012e835 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -208,6 +208,35 @@ void LLFloaterIMNearbyChat::closeHostedFloater()
 	}
 }
 
+void LLFloaterIMNearbyChat::closeFloater(bool app_quitting)
+{
+	LLFloaterEmojiPicker::saveState();
+
+	// If detached from conversations window close anyway
+	if (!getHost())
+	{
+		LLFloaterIMSessionTab::closeFloater(app_quitting);
+	}
+
+	// Should check how many conversations are ongoing. Select next to "Nearby Chat" in case there are some other besides.
+	// Close conversations window in case "Nearby Chat" is attached and the only conversation
+	LLFloaterIMContainer* floater_container = LLFloaterIMContainer::getInstance();
+	if (floater_container->getConversationListItemSize() == 1)
+	{
+		if (getHost())
+		{
+			floater_container->closeFloater(app_quitting);
+		}
+	}
+	else
+	{
+		if (!getHost())
+		{
+			floater_container->selectNextConversationByID(LLUUID());
+		}
+	}
+}
+
 // virtual
 void LLFloaterIMNearbyChat::refresh()
 {
diff --git a/indra/newview/llfloaterimnearbychat.h b/indra/newview/llfloaterimnearbychat.h
index ca52b97b677..c3db4943abf 100644
--- a/indra/newview/llfloaterimnearbychat.h
+++ b/indra/newview/llfloaterimnearbychat.h
@@ -65,6 +65,8 @@ class LLFloaterIMNearbyChat final
 	/*virtual*/ void setVisibleAndFrontmost(BOOL take_focus=TRUE, const LLSD& key = LLSD()) override;
 	/*virtual*/ void closeHostedFloater() override;
 
+	void	closeFloater(bool app_quitting = false) override;
+
 	void loadHistory();
     void reloadMessages(bool clean_messages = false);
 	void removeScreenChat();
-- 
GitLab