From cbeaf3d7a0dd7bdb739b8e72addd41410940a8f5 Mon Sep 17 00:00:00 2001
From: Paul ProductEngine <pguslisty@productengine.com>
Date: Fri, 30 Dec 2011 18:32:04 +0200
Subject: [PATCH] EXP-1586 FIXED (Nearby chat window no longer persists between
 viewer startups)

- Visibility state of chat floater is saved between sessions
- Also visibility state of chat history in nearby chat floater is saved too
---
 indra/newview/llnearbychatbar.cpp             | 25 +++++++++++++++++++
 indra/newview/llnearbychatbar.h               |  5 ++++
 .../skins/default/xui/en/floater_chat_bar.xml |  1 +
 3 files changed, 31 insertions(+)

diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index eec09653841..cb08ca8862c 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -109,6 +109,17 @@ BOOL LLNearbyChatBar::postBuild()
 	mOutputMonitor = getChild<LLOutputMonitorCtrl>("chat_zone_indicator");
 	mOutputMonitor->setVisible(FALSE);
 
+	gSavedSettings.declareBOOL("nearbychat_history_visibility", mNearbyChat->getVisible(), "Visibility state of nearby chat history", TRUE);
+
+	// If mVisibilityControl is not empty it means that the visibility state of floater is saved between sessions,
+	// i.e. save_visibility="true" for this floater.
+	// So if we need to restore visibility state of floater we also need to restore visibility state of nearby chat history.
+	if (!mVisibilityControl.empty())
+	{
+		// restore visibility of nearby chat history
+		mNearbyChat->setVisible(gSavedSettings.getBOOL("nearbychat_history_visibility"));
+	}
+
 	// Register for font change notifications
 	LLViewerChat::setFontChangedCallback(boost::bind(&LLNearbyChatBar::onChatFontChange, this, _1));
 
@@ -141,6 +152,18 @@ bool LLNearbyChatBar::applyRectControl()
 	return rect_controlled;
 }
 
+void LLNearbyChatBar::saveChatHistoryVisibility()
+{
+	// save visibility state of nearby chat history panel if
+	// visibility of nearby chat floater is saved, i.e. save_visisbility="true"
+	// (if save_visisbility="true", mVisibilityControl == "floater_vis_chat_bar")
+	if (mVisibilityControl.size() > 1)
+	{
+		// save visibility of nearby chat history
+		gSavedSettings.setBOOL("nearbychat_history_visibility", mNearbyChat->getVisible());
+	}
+}
+
 void LLNearbyChatBar::onChatFontChange(LLFontGL* fontp)
 {
 	// Update things with the new font whohoo
@@ -413,6 +436,8 @@ void LLNearbyChatBar::onToggleNearbyChatPanel()
 		enableResizeCtrls(true);
 		storeRectControl();
 	}
+
+	saveChatHistoryVisibility();
 }
 
 void LLNearbyChatBar::setMinimized(BOOL b)
diff --git a/indra/newview/llnearbychatbar.h b/indra/newview/llnearbychatbar.h
index baf12a06ea0..84040b8aab2 100644
--- a/indra/newview/llnearbychatbar.h
+++ b/indra/newview/llnearbychatbar.h
@@ -92,6 +92,11 @@ class LLNearbyChatBar :	public LLFloater
 	LLLocalSpeakerMgr*		mSpeakerMgr;
 
 	S32 mExpandedHeight;
+private:
+
+	// Saves visibility of chat history panel
+	// if save_visibility="true"
+	void saveChatHistoryVisibility();
 };
 
 #endif
diff --git a/indra/newview/skins/default/xui/en/floater_chat_bar.xml b/indra/newview/skins/default/xui/en/floater_chat_bar.xml
index 675f78d911a..63992462b34 100644
--- a/indra/newview/skins/default/xui/en/floater_chat_bar.xml
+++ b/indra/newview/skins/default/xui/en/floater_chat_bar.xml
@@ -9,6 +9,7 @@
  single_instance="true"
  title="NEARBY CHAT"
  save_rect="true"
+ save_visibility="true"
  can_close="true"
  can_minimize="true"
  help_topic="chat_bar"
-- 
GitLab