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.
- Listed in Menus, UI and platforms
- Inherits or implements
LoggedInTool - Nested types
Tab
Constructors
| Member | What it is |
|---|---|
FriendsManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private readonly List<UserToken> activeTokens | User tokens currently on the board. |
private IAnalyticsService analyticsService | Analytics service, injected, used to log friend request responses. |
private FriendsManager.Tab currentTab | The tab being shown. Set to friends on log in. |
private RopePoweredElementBoard displayBoard | Rope-powered board the user tokens are laid out on. |
private readonly Dictionary<int, FriendshipInfo> friendships | Accepted friendships keyed by friendship id. Cleared on log out. |
private readonly List<FriendshipInfo> friendshipsRequests | Pending friend requests from the last fetch. |
private bool isProcessing | Busy flag for API calls. AddFriend leaves it set to true, so after one add the manager ignores further actions. |
private readonly Stack<UserToken> tokenPool | Hidden user tokens kept for reuse. |
private UserToken userTokenPrefab | Prefab for one user entry on the board. |
Properties
1 private and internal property
| Member | What it is |
|---|---|
private IEnumerable<FriendshipInfo> Friendships { get; } | Accepted friendships from the last fetch. |
Methods
| Member | What 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
| Member | What 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: