From 92afbfaf88764e9be75458c5e2b2514e59a0deed Mon Sep 17 00:00:00 2001 From: Mike Antipov Date: Thu, 29 Jul 2010 15:52:36 +0300 Subject: EXT-7706 FIXED Implemented delayed friends cards synchronization and filling People/Friends tab with data until it is visible to user first time. * Moved location of synchronization of the Friends/All inventory folder with friends list from startup to first requesting of data. * Also updated "update Friends list" logic to be really trigged only when Friends tab is visible to user. NOTE: * Friends List/All is filled with some delay on first opening. TODO: refactoring is needed to switch code of updating People/nearby list to use the same approach as for Friends. Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/805/ --HG-- branch : product-engine --- indra/newview/llpanelpeople.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpanelpeople.cpp') diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp index 6dd800c0c6..3140fe8de1 100644 --- a/indra/newview/llpanelpeople.cpp +++ b/indra/newview/llpanelpeople.cpp @@ -272,6 +272,7 @@ public: friend class LLInventoryFriendCardObserver; LLFriendListUpdater(callback_t cb) : LLAvatarListUpdater(cb, FRIEND_LIST_UPDATE_TIMEOUT) + , mIsActive(false) { LLAvatarTracker::instance().addObserver(this); @@ -290,9 +291,12 @@ public: /*virtual*/ void changed(U32 mask) { - // events can arrive quickly in bulk - we need not process EVERY one of them - - // so we wait a short while to let others pile-in, and process them in aggregate. - mEventTimer.start(); + if (mIsActive) + { + // events can arrive quickly in bulk - we need not process EVERY one of them - + // so we wait a short while to let others pile-in, and process them in aggregate. + mEventTimer.start(); + } // save-up all the mask-bits which have come-in mMask |= mask; @@ -301,8 +305,12 @@ public: /*virtual*/ BOOL tick() { + if (!mIsActive) return FALSE; + if (mMask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE)) + { updateList(); + } // Stop updates. mEventTimer.stop(); @@ -311,9 +319,20 @@ public: return FALSE; } + // virtual + void setActive(bool active) + { + mIsActive = active; + if (active) + { + tick(); + } + } + private: U32 mMask; LLInventoryFriendCardObserver* mInvObserver; + bool mIsActive; /** * This class is intended for updating Friend List when Inventory Friend Card is added/removed. @@ -504,8 +523,11 @@ BOOL LLPanelPeople::postBuild() mTabContainer = getChild("tabs"); mTabContainer->setCommitCallback(boost::bind(&LLPanelPeople::onTabSelected, this, _2)); - mOnlineFriendList = getChild(FRIENDS_TAB_NAME)->getChild("avatars_online"); - mAllFriendList = getChild(FRIENDS_TAB_NAME)->getChild("avatars_all"); + LLPanel* friends_tab = getChild(FRIENDS_TAB_NAME); + // updater is active only if panel is visible to user. + friends_tab->setVisibleCallback(boost::bind(&Updater::setActive, mFriendListUpdater, _2)); + mOnlineFriendList = friends_tab->getChild("avatars_online"); + mAllFriendList = friends_tab->getChild("avatars_all"); mOnlineFriendList->setNoItemsCommentText(getString("no_friends_online")); mOnlineFriendList->setShowIcons("FriendsListShowIcons"); mAllFriendList->setNoItemsCommentText(getString("no_friends")); -- cgit v1.2.3