From 6bcf7a6fe64457ad5f1dc2939820e45182476842 Mon Sep 17 00:00:00 2001
From: James Cook <james@lindenlab.com>
Date: Wed, 19 Aug 2009 18:43:46 +0000
Subject: EXT-592 IM chat is not updated for the first text message.  PE added
 LLIMFloater::toggle() to show and hide the IM window when chiclets were
 clicked.  This was not invoking the custom logic in LLIMFloater::show() that
 causes the message list to update.  Reviewed with Leyla.

---
 indra/newview/llimpanel.cpp | 17 +++++++++++++++--
 indra/newview/llimpanel.h   |  4 +++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index 65bf1176ff..954da8abd7 100644
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -2232,9 +2232,22 @@ LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
 }
 
 //static
-BOOL LLIMFloater::toggle(const LLUUID& session_id)
+bool LLIMFloater::toggle(const LLUUID& session_id)
 {
-	return LLFloaterReg::toggleInstance("impanel", session_id);
+	LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
+	if (floater && floater->getVisible())
+	{
+		// clicking on chiclet to close floater just hides it to maintain existing
+		// scroll/text entry state
+		floater->setVisible(false);
+		return false;
+	}
+	else
+	{
+		// ensure the list of messages is updated when floater is made visible
+		show(session_id);
+		return true;
+	}
 }
 
 void LLIMFloater::updateMessages()
diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h
index 52f67df4b7..284a486b0f 100644
--- a/indra/newview/llimpanel.h
+++ b/indra/newview/llimpanel.h
@@ -384,10 +384,12 @@ public:
 	// LLFloater overrides
 	/*virtual*/ void setDocked(bool docked,  bool pop_on_undock = true);
 
+	// Make IM conversion visible and update the message history
 	static LLIMFloater* show(const LLUUID& session_id);
 
 	// Toggle panel specified by session_id
-	static BOOL toggle(const LLUUID& session_id);
+	// Returns true iff panel became visible
+	static bool toggle(const LLUUID& session_id);
 
 	// get new messages from LLIMModel
 	void updateMessages();
-- 
cgit v1.2.3