summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llchiclet.cpp2
-rw-r--r--indra/newview/llimfloater.cpp16
-rw-r--r--indra/newview/llimview.cpp23
-rw-r--r--indra/newview/llimview.h11
4 files changed, 47 insertions, 5 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 8efa814a2e..1f92686a43 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -1137,7 +1137,7 @@ void im_chiclet_callback(LLChicletPanel* panel, const LLSD& data){
S32 unread = data["participant_unread"].asInteger();
LLIMFloater* im_floater = LLIMFloater::findInstance(session_id);
- if (im_floater && im_floater->getVisible())
+ if (im_floater && im_floater->getVisible() && im_floater->hasFocus())
{
unread = 0;
}
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index f0e195c37a..91f4f57e54 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -128,6 +128,11 @@ void LLIMFloater::onFocusReceived()
LLIMModel::getInstance()->setActiveSessionID(mSessionID);
LLBottomTray::getInstance()->getChicletPanel()->setChicletToggleState(mSessionID, true);
+
+ if (getVisible())
+ {
+ LLIMModel::instance().sendNoUnreadMessages(mSessionID);
+ }
}
// virtual
@@ -609,7 +614,16 @@ void LLIMFloater::updateMessages()
bool use_plain_text_chat_history = gSavedSettings.getBOOL("PlainTextChatHistory");
std::list<LLSD> messages;
- LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1);
+
+ // we shouldn't reset unread message counters if IM floater doesn't have focus
+ if (hasFocus())
+ {
+ LLIMModel::instance().getMessages(mSessionID, messages, mLastMessageIndex+1);
+ }
+ else
+ {
+ LLIMModel::instance().getMessagesSilently(mSessionID, messages, mLastMessageIndex+1);
+ }
if (messages.size())
{
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 6ce06adc80..7a4febec20 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -608,10 +608,10 @@ bool LLIMModel::clearSession(const LLUUID& session_id)
return true;
}
-void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
+void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
{
LLIMSession* session = findIMSession(session_id);
- if (!session)
+ if (!session)
{
llwarns << "session " << session_id << "does not exist " << llendl;
return;
@@ -619,7 +619,7 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
int i = session->mMsgs.size() - start_index;
- for (std::list<LLSD>::iterator iter = session->mMsgs.begin();
+ for (std::list<LLSD>::iterator iter = session->mMsgs.begin();
iter != session->mMsgs.end() && i > 0;
iter++)
{
@@ -628,6 +628,16 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
messages.push_back(*iter);
i--;
}
+}
+
+void LLIMModel::sendNoUnreadMessages(const LLUUID& session_id)
+{
+ LLIMSession* session = findIMSession(session_id);
+ if (!session)
+ {
+ llwarns << "session " << session_id << "does not exist " << llendl;
+ return;
+ }
session->mNumUnread = 0;
session->mParticipantUnreadMessageCount = 0;
@@ -639,6 +649,13 @@ void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages,
mNoUnreadMsgsSignal(arg);
}
+void LLIMModel::getMessages(const LLUUID& session_id, std::list<LLSD>& messages, int start_index)
+{
+ getMessagesSilently(session_id, messages, start_index);
+
+ sendNoUnreadMessages(session_id);
+}
+
bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from, const LLUUID& from_id, const std::string& utf8_text) {
LLIMSession* session = findIMSession(session_id);
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index e7404074e0..f1693d0e17 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -178,6 +178,17 @@ public:
bool clearSession(const LLUUID& session_id);
/**
+ * Populate supplied std::list with messages starting from index specified by start_index without
+ * emitting no unread messages signal.
+ */
+ void getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& messages, int start_index = 0);
+
+ /**
+ * Sends no unread messages signal.
+ */
+ void sendNoUnreadMessages(const LLUUID& session_id);
+
+ /**
* Populate supplied std::list with messages starting from index specified by start_index
*/
void getMessages(const LLUUID& session_id, std::list<LLSD>& messages, int start_index = 0);