Skip to content
Snippets Groups Projects
Commit 8dae4c26 authored by Alexei Arabadji's avatar Alexei Arabadji
Browse files

fixed EXT-6736 Notecard floater missing Keep/Discard Buttons (vwr 2.0)

Added functionality to close hidden IM toasts when IM floater opens.

reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/321/

--HG--
branch : product-engine
parent 38086b74
No related branches found
No related tags found
No related merge requests found
...@@ -243,3 +243,19 @@ void LLChannelManager::killToastsFromChannel(const LLUUID& channel_id, const LLS ...@@ -243,3 +243,19 @@ void LLChannelManager::killToastsFromChannel(const LLUUID& channel_id, const LLS
} }
} }
// static
LLNotificationsUI::LLScreenChannel* LLChannelManager::getNotificationScreenChannel()
{
LLNotificationsUI::LLScreenChannel* channel = static_cast<LLNotificationsUI::LLScreenChannel*>
(LLNotificationsUI::LLChannelManager::getInstance()->
findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID"))));
if (channel == NULL)
{
llwarns << "Can't find screen channel by NotificationChannelUUID" << llendl;
llassert(!"Can't find screen channel by NotificationChannelUUID");
}
return channel;
}
...@@ -114,6 +114,11 @@ class LLChannelManager : public LLSingleton<LLChannelManager> ...@@ -114,6 +114,11 @@ class LLChannelManager : public LLSingleton<LLChannelManager>
*/ */
void killToastsFromChannel(const LLUUID& channel_id, const LLScreenChannel::Matcher& matcher); void killToastsFromChannel(const LLUUID& channel_id, const LLScreenChannel::Matcher& matcher);
/**
* Returns notification screen channel.
*/
static LLNotificationsUI::LLScreenChannel* getNotificationScreenChannel();
private: private:
LLScreenChannel* createChannel(LLChannelManager::Params& p); LLScreenChannel* createChannel(LLChannelManager::Params& p);
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "llsyswellwindow.h" #include "llsyswellwindow.h"
#include "lltrans.h" #include "lltrans.h"
#include "llchathistory.h" #include "llchathistory.h"
#include "llnotifications.h"
#include "llviewerwindow.h" #include "llviewerwindow.h"
#include "llvoicechannel.h" #include "llvoicechannel.h"
#include "lltransientfloatermgr.h" #include "lltransientfloatermgr.h"
...@@ -371,6 +372,8 @@ void LLIMFloater::onSlide() ...@@ -371,6 +372,8 @@ void LLIMFloater::onSlide()
//static //static
LLIMFloater* LLIMFloater::show(const LLUUID& session_id) LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
{ {
closeHiddenIMToasts();
if (!gIMMgr->hasSession(session_id)) return NULL; if (!gIMMgr->hasSession(session_id)) return NULL;
if(!isChatMultiTab()) if(!isChatMultiTab())
...@@ -1083,6 +1086,26 @@ void LLIMFloater::removeTypingIndicator(const LLIMInfo* im_info) ...@@ -1083,6 +1086,26 @@ void LLIMFloater::removeTypingIndicator(const LLIMInfo* im_info)
} }
} }
// static
void LLIMFloater::closeHiddenIMToasts()
{
class IMToastMatcher: public LLNotificationsUI::LLScreenChannel::Matcher
{
public:
bool matches(const LLNotificationPtr notification) const
{
// "notifytoast" type of notifications is reserved for IM notifications
return "notifytoast" == notification->getType();
}
};
LLNotificationsUI::LLScreenChannel* channel = LLNotificationsUI::LLChannelManager::getNotificationScreenChannel();
if (channel != NULL)
{
channel->closeHiddenToasts(IMToastMatcher());
}
}
// static // static
bool LLIMFloater::isChatMultiTab() bool LLIMFloater::isChatMultiTab()
{ {
......
...@@ -148,6 +148,8 @@ class LLIMFloater : public LLTransientDockableFloater ...@@ -148,6 +148,8 @@ class LLIMFloater : public LLTransientDockableFloater
// Remove the "User is typing..." indicator. // Remove the "User is typing..." indicator.
void removeTypingIndicator(const LLIMInfo* im_info = NULL); void removeTypingIndicator(const LLIMInfo* im_info = NULL);
static void closeHiddenIMToasts();
LLPanelChatControlPanel* mControlPanel; LLPanelChatControlPanel* mControlPanel;
LLUUID mSessionID; LLUUID mSessionID;
S32 mLastMessageIndex; S32 mLastMessageIndex;
......
...@@ -706,6 +706,31 @@ void LLScreenChannel::hideToast(const LLUUID& notification_id) ...@@ -706,6 +706,31 @@ void LLScreenChannel::hideToast(const LLUUID& notification_id)
} }
} }
void LLScreenChannel::closeHiddenToasts(const Matcher& matcher)
{
// since we can't guarantee that close toast operation doesn't change mToastList
// we collect matched toasts that should be closed into separate list
std::list<ToastElem> toasts;
for (std::vector<ToastElem>::iterator it = mToastList.begin(); it
!= mToastList.end(); it++)
{
LLToast * toast = it->toast;
// add to list valid toast that match to provided matcher criteria
if (toast != NULL && !toast->isDead() && toast->getNotification() != NULL
&& !toast->getVisible() && matcher.matches(toast->getNotification()))
{
toasts.push_back(*it);
}
}
// close collected toasts
for (std::list<ToastElem>::iterator it = toasts.begin(); it
!= toasts.end(); it++)
{
it->toast->closeFloater();
}
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void LLScreenChannel::removeToastsFromChannel() void LLScreenChannel::removeToastsFromChannel()
{ {
......
...@@ -173,6 +173,12 @@ class LLScreenChannel : public LLScreenChannelBase ...@@ -173,6 +173,12 @@ class LLScreenChannel : public LLScreenChannelBase
void hideToastsFromScreen(); void hideToastsFromScreen();
// hide toast by notification id // hide toast by notification id
void hideToast(const LLUUID& notification_id); void hideToast(const LLUUID& notification_id);
/**
* Closes hidden matched toasts from channel.
*/
void closeHiddenToasts(const Matcher& matcher);
// removes all toasts from a channel // removes all toasts from a channel
void removeToastsFromChannel(); void removeToastsFromChannel();
// show all toasts in a channel // show all toasts in a channel
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment