From 2d0ca224ea7a05a38e51979d201e55b7e942c855 Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Fri, 19 Mar 2010 17:27:54 +0200 Subject: =?UTF-8?q?fixed=20EXT-6472=20=E2=80=9CNo=20indication=20about=20n?= =?UTF-8?q?ew=20message/offer=20if=20IM=20window=20is=20open=20but=20not?= =?UTF-8?q?=20in=20focus=E2=80=9D,=20allowed=20to=20increment=20IM=20messa?= =?UTF-8?q?ge=20counter=20when=20IM=20window=20is=20opened=20but=20doesn't?= =?UTF-8?q?=20have=20focus=20and=20reset=20IM=20counter=20when=20IM=20wind?= =?UTF-8?q?ow=20get=20focus;=20reviewed=20by=20Mike=20Antipov=20at=20https?= =?UTF-8?q?://codereview.productengine.com/secondlife/r/76/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --HG-- branch : product-engine --- indra/newview/llchiclet.cpp | 2 +- indra/newview/llimfloater.cpp | 16 +++++++++++++++- indra/newview/llimview.cpp | 23 ++++++++++++++++++++--- indra/newview/llimview.h | 11 +++++++++++ 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 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& messages, int start_index) +void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list& 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& messages, int i = session->mMsgs.size() - start_index; - for (std::list::iterator iter = session->mMsgs.begin(); + for (std::list::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& 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& messages, mNoUnreadMsgsSignal(arg); } +void LLIMModel::getMessages(const LLUUID& session_id, std::list& 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 @@ -177,6 +177,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& 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 */ -- cgit v1.2.3