diff options
| author | James Cook <james@lindenlab.com> | 2009-09-28 23:11:18 +0000 |
|---|---|---|
| committer | James Cook <james@lindenlab.com> | 2009-09-28 23:11:18 +0000 |
| commit | 76dd17168a6ec7f588a862b9575995687cd49b0f (patch) | |
| tree | 3ec1bb6f3a32f9c9c94132559fdd12dff8502ace /indra/newview/llavatariconctrl.cpp | |
| parent | a744ffcef4add32e8fa9a6ce61deae0c29f649c4 (diff) | |
DEV-40528 Viewer 2 floods server with AvatarPropertiesRequest messages causing database load. Icon cache was only being used to provide images more quickly, not to suppress network traffic. Made it suppress network traffic, which may result in stale icons occasionally. Converted online/offline tooltip to use LLAvatarTracker. Will port to viewer-2-qa-1. Reviewed with Richard.
Diffstat (limited to 'indra/newview/llavatariconctrl.cpp')
| -rw-r--r-- | indra/newview/llavatariconctrl.cpp | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp index a8b1ff6c92..1d5fa9ffa7 100644 --- a/indra/newview/llavatariconctrl.cpp +++ b/indra/newview/llavatariconctrl.cpp @@ -32,9 +32,10 @@ #include "llviewerprecompiledheaders.h" +#include "llavatariconctrl.h" + #include "llagent.h" #include "llavatarconstants.h" -#include "llavatariconctrl.h" #include "llcallingcard.h" // for LLAvatarTracker #include "llavataractions.h" #include "llimview.h" @@ -139,25 +140,37 @@ void LLAvatarIconCtrl::setValue(const LLSD& value) { if (value.isUUID()) { + LLAvatarPropertiesProcessor* app = + LLAvatarPropertiesProcessor::getInstance(); if (mAvatarId.notNull()) { - LLAvatarPropertiesProcessor::getInstance()->removeObserver(mAvatarId, this); + app->removeObserver(mAvatarId, this); } if (mAvatarId != value.asUUID()) { - LLAvatarPropertiesProcessor::getInstance()->addObserver(value.asUUID(), this); - LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(value.asUUID()); mAvatarId = value.asUUID(); - // Check if cache already contains image_id for that avatar - avatar_image_map_t::iterator it; + // *BUG: This will return stale icons if a user changes their + // profile picture. Also, the online/offline tooltips will be + // out of date. However, otherwise we send too many upstream + // AvatarPropertiesRequest messages. + // + // *TODO: Implement a timeout on the icon cache, perhaps a day?, + // and make the cache update if a user views the full-profile for + // an avatar. - it = sImagesCache.find(mAvatarId); + // Check if cache already contains image_id for that avatar + avatar_image_map_t::iterator it = sImagesCache.find(mAvatarId); if (it != sImagesCache.end()) { updateFromCache(it->second); } + else + { + app->addObserver(value.asUUID(), this); + app->sendAvatarPropertiesRequest(value.asUUID()); + } } } @@ -181,21 +194,34 @@ void LLAvatarIconCtrl::updateFromCache(LLAvatarIconCtrl::LLImagesCacheItem data) LLIconCtrl::setValue("default_profile_picture.j2c"); } - // Update color of status symbol and tool tip - if (data.flags & AVATAR_ONLINE) + // Can only see online status of friends + if (LLAvatarTracker::instance().isBuddy(mAvatarId)) { - mStatusSymbol->setColor(LLColor4::green); - if (mDrawTooltip) + if (LLAvatarTracker::instance().isBuddyOnline(mAvatarId)) { - setToolTip((LLStringExplicit)"Online"); + // Update color of status symbol and tool tip + mStatusSymbol->setColor(LLColor4::green); + if (mDrawTooltip) + { + setToolTip((LLStringExplicit)"Online"); + } + } + else + { + mStatusSymbol->setColor(LLColor4::grey); + if (mDrawTooltip) + { + setToolTip((LLStringExplicit)"Offline"); + } } } else { + // Not a buddy, no information mStatusSymbol->setColor(LLColor4::grey); if (mDrawTooltip) { - setToolTip((LLStringExplicit)"Offline"); + setToolTip((LLStringExplicit)""); } } } |
