Skip to main content

FriendsManager

A class in Root.Township, Alta.Meta.Friends.

Main menu friends board: lists friends or friend requests from the Alta API as user tokens on a rope board. Client side.

Constructors​

MemberWhat it is
FriendsManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

9 private and internal fields
MemberWhat it is
private readonly List<UserToken> activeTokensUser tokens currently on the board.
private IAnalyticsService analyticsServiceAnalytics service, injected, used to log friend request responses.
private FriendsManager.Tab currentTabThe tab being shown. Set to friends on log in.
private RopePoweredElementBoard displayBoardRope-powered board the user tokens are laid out on.
private readonly Dictionary<int, FriendshipInfo> friendshipsAccepted friendships keyed by friendship id. Cleared on log out.
private readonly List<FriendshipInfo> friendshipsRequestsPending friend requests from the last fetch.
private bool isProcessingBusy flag for API calls. AddFriend leaves it set to true, so after one add the manager ignores further actions.
private readonly Stack<UserToken> tokenPoolHidden user tokens kept for reuse.
private UserToken userTokenPrefabPrefab for one user entry on the board.

Properties​

1 private and internal property
MemberWhat it is
private IEnumerable<FriendshipInfo> Friendships { get; }Accepted friendships from the last fetch.

Methods​

MemberWhat it is
async void AddFriend(UserToken token)Sends or accepts a friend request and removes the token. Leaves isProcessing set, so later add and remove clicks do nothing.
void ChangeTab(int index)Switches between the friends, requests and Oculus tabs and redraws the board. The Oculus tab always shows nothing.
void ChangeTab(FriendsManager.Tab tab)Switches between the friends, requests and Oculus tabs and redraws the board. The Oculus tab always shows nothing.
void Inject(IAnalyticsService analyticsService)Receives the analytics service by dependency injection.
void JoinFriendServer(UserToken token)Empty in this build; does nothing.
async void RemoveFriend(UserToken token)Removes the friendship through the API and removes the token. The list refresh is skipped, since isProcessing is already set.
protected override async void LoggedIn()Loads friends and requests and shows the friends tab.
protected override void LoggedOut()Clears the friends list.
protected override void OnDestroy()Destroys all user tokens, shown and pooled.
7 private and internal methods
MemberWhat it is
private void ConfigureTokenForTab(UserToken token, UserInfo user)Sets a user token's buttons for the current tab: join (which does nothing) and remove for friends, accept and decline for requests, add only for Oculus.
private void DisplayUser(UserInfo user)Takes a token from the pool (or makes one), sets it up for the user and adds it to the board.
private IEnumerable<UserInfo> GetUserInfoToDisplay()Users for the current tab, sorted by username. The Oculus tab always comes back empty.
private void ReleaseToken(UserToken token)Hides a token, returns it to the pool and removes it from the board.
private void ResetDisplay()Returns every shown token to the pool and clears the board.
private void UpdateDisplay()Rebuilds the board from the current tab's users and scrolls it back to the start.
private async Task UpdateFriends()Fetches friends and friend requests from the social API. Does nothing while isProcessing is set, which it is when AddFriend and RemoveFriend call it.

Used in​

Members of other types that take, return or hold a FriendsManager: