diff options
| author | Merov Linden <merov@lindenlab.com> | 2014-02-28 13:54:22 -0800 | 
|---|---|---|
| committer | Merov Linden <merov@lindenlab.com> | 2014-02-28 13:54:22 -0800 | 
| commit | 209ed601dd6cf9af66eb44d71ab0d28ec94fb81e (patch) | |
| tree | 16905d6a119e563567d586bf1ffbbe6ca000915f /indra | |
| parent | 261e728327ce72bc582f41cbb231035f0ee1f9b1 (diff) | |
ACME-1332 : Update the friends lists in the FB Friends panel when friend status (add/remove) changes
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llfloaterfacebook.cpp | 48 | ||||
| -rw-r--r-- | indra/newview/llfloaterfacebook.h | 5 | 
2 files changed, 28 insertions, 25 deletions
| diff --git a/indra/newview/llfloaterfacebook.cpp b/indra/newview/llfloaterfacebook.cpp index 4e6dd002ed..5acc5260d2 100644 --- a/indra/newview/llfloaterfacebook.cpp +++ b/indra/newview/llfloaterfacebook.cpp @@ -757,6 +757,11 @@ mSuggestedFriends(NULL)  {  } +LLFacebookFriendsPanel::~LLFacebookFriendsPanel() +{ +    LLAvatarTracker::instance().removeObserver(this); +} +  BOOL LLFacebookFriendsPanel::postBuild()  {  	mSecondLifeFriends = getChild<LLAvatarList>("second_life_friends"); @@ -767,6 +772,8 @@ BOOL LLFacebookFriendsPanel::postBuild()  	setVisibleCallback(boost::bind(&LLFacebookFriendsPanel::updateFacebookList, this, _2)); +    LLAvatarTracker::instance().addObserver(this); +      	return LLPanel::postBuild();  } @@ -815,42 +822,35 @@ void LLFacebookFriendsPanel::showFriendsAccordionsIfNeeded()  	// Rearrange accordions  	LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("friends_accordion");  	accordion->arrange(); +} -	// *TODO: new no_matched_tabs_text attribute was implemented in accordion (EXT-7368). -	// this code should be refactored to use it -	// keep help text in a synchronization with accordions visibility. -	//updateFriendListHelpText(); +void LLFacebookFriendsPanel::changed(U32 mask) +{ +	if (mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE)) +	{ +		updateFacebookList(true); +	}  } +  void LLFacebookFriendsPanel::updateFacebookList(bool visible)  {  	if (visible)  	{ -		LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople"); // just in case it is already listening -		LLEventPumps::instance().obtain("FacebookConnectContent").listen("LLPanelPeople", boost::bind(&LLFacebookFriendsPanel::updateSuggestedFriendList, this)); - -		LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople"); // just in case it is already listening -		LLEventPumps::instance().obtain("FacebookConnectState").listen("LLPanelPeople", boost::bind(&LLFacebookFriendsPanel::onConnectedToFacebook, this, _1)); - -		//Connected -		if (LLFacebookConnect::instance().isConnected()) -		{ -			LLFacebookConnect::instance().loadFacebookFriends(); -		} -		//Check if connected +		// Try to connect to Facebook          if ((LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_NOT_CONNECTED) ||              (LLFacebookConnect::instance().getConnectionState() == LLFacebookConnect::FB_CONNECTION_FAILED))          {              LLFacebookConnect::instance().checkConnectionToFacebook();          } - +		// Loads FB friends +		if (LLFacebookConnect::instance().isConnected()) +		{ +			LLFacebookConnect::instance().loadFacebookFriends(); +		} +        // Sort the FB friends and update the lists  		updateSuggestedFriendList();  	} -	else -	{ -		LLEventPumps::instance().obtain("FacebookConnectState").stopListening("LLPanelPeople"); -		LLEventPumps::instance().obtain("FacebookConnectContent").stopListening("LLPanelPeople"); -	}  }  bool LLFacebookFriendsPanel::onConnectedToFacebook(const LLSD& data) @@ -861,10 +861,10 @@ bool LLFacebookFriendsPanel::onConnectedToFacebook(const LLSD& data)  	{  		LLFacebookConnect::instance().loadFacebookFriends();  	} -	else if(connection_state == LLFacebookConnect::FB_NOT_CONNECTED) +	else if (connection_state == LLFacebookConnect::FB_NOT_CONNECTED)  	{  		updateSuggestedFriendList(); -	}; +	}  	return false;  } diff --git a/indra/newview/llfloaterfacebook.h b/indra/newview/llfloaterfacebook.h index 16c9e97ff0..39264c8bff 100644 --- a/indra/newview/llfloaterfacebook.h +++ b/indra/newview/llfloaterfacebook.h @@ -27,6 +27,7 @@  #ifndef LL_LLFLOATERFACEBOOK_H  #define LL_LLFLOATERFACEBOOK_H +#include "llcallingcard.h"  #include "llfloater.h"  #include "lltextbox.h"  #include "llviewertexture.h" @@ -128,11 +129,13 @@ private:      bool mReloadingMapTexture;  }; -class LLFacebookFriendsPanel : public LLPanel +class LLFacebookFriendsPanel : public LLPanel, public LLFriendObserver  {  public:  	LLFacebookFriendsPanel(); +	~LLFacebookFriendsPanel();  	BOOL postBuild(); +	virtual void changed(U32 mask);  private:  	bool updateSuggestedFriendList(); | 
