| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | | using DCL; |
| | 6 | | using DCL.Helpers; |
| | 7 | | using TMPro; |
| | 8 | | using UnityEngine; |
| | 9 | | using UnityEngine.UI; |
| | 10 | |
|
| | 11 | | public class FriendRequestsTabComponentView : BaseComponentView |
| | 12 | | { |
| | 13 | | private const string FRIEND_ENTRIES_POOL_NAME_PREFIX = "FriendRequestEntriesPool_"; |
| | 14 | | private const string NOTIFICATIONS_ID = "Friends"; |
| | 15 | | private const int PRE_INSTANTIATED_ENTRIES = 25; |
| | 16 | | private const float NOTIFICATIONS_DURATION = 3; |
| | 17 | | private const int AVATAR_SNAPSHOTS_PER_FRAME = 5; |
| | 18 | | private const int CREATION_AMOUNT_PER_FRAME = 5; |
| | 19 | | private const float REQUEST_MORE_ENTRIES_SCROLL_THRESHOLD = 0.005f; |
| | 20 | | private const float MIN_TIME_TO_REQUIRE_MORE_ENTRIES = 0.5f; |
| | 21 | |
|
| | 22 | | [SerializeField] private GameObject enabledHeader; |
| | 23 | | [SerializeField] private GameObject disabledHeader; |
| | 24 | | [SerializeField] private GameObject emptyStateContainer; |
| | 25 | | [SerializeField] private GameObject filledStateContainer; |
| | 26 | | [SerializeField] private FriendRequestEntry entryPrefab; |
| | 27 | | [SerializeField] private CollapsableSortedFriendEntryList receivedRequestsList; |
| | 28 | | [SerializeField] private CollapsableSortedFriendEntryList sentRequestsList; |
| | 29 | | [SerializeField] private SearchBarComponentView searchBar; |
| | 30 | | [SerializeField] private TMP_Text receivedRequestsCountText; |
| | 31 | | [SerializeField] private TMP_Text sentRequestsCountText; |
| | 32 | | [SerializeField] private UserContextMenu contextMenuPanel; |
| | 33 | | [SerializeField] private RectTransform viewport; |
| | 34 | | [SerializeField] internal ScrollRect scroll; |
| | 35 | |
|
| | 36 | | [Header("Notifications")] [SerializeField] |
| | 37 | | private Notification requestSentNotification; |
| | 38 | |
|
| | 39 | | [SerializeField] private Notification friendSearchFailedNotification; |
| | 40 | | [SerializeField] private Notification acceptedFriendNotification; |
| | 41 | | [SerializeField] private Notification alreadyFriendsNotification; |
| | 42 | | [SerializeField] private Model model; |
| | 43 | |
|
| | 44 | | [Header("Load More Entries")] |
| | 45 | | [SerializeField] internal GameObject loadMoreEntriesContainer; |
| | 46 | | [SerializeField] internal TMP_Text loadMoreEntriesLabel; |
| | 47 | | [SerializeField] internal GameObject loadMoreEntriesSpinner; |
| | 48 | |
|
| 2 | 49 | | private readonly Dictionary<string, PoolableObject> pooleableEntries = new Dictionary<string, PoolableObject>(); |
| 2 | 50 | | private readonly Dictionary<string, FriendRequestEntry> entries = new Dictionary<string, FriendRequestEntry>(); |
| 2 | 51 | | private readonly Dictionary<string, FriendRequestEntryModel> creationQueue = |
| | 52 | | new Dictionary<string, FriendRequestEntryModel>(); |
| | 53 | | private Pool entryPool; |
| | 54 | | private string lastRequestSentUserName; |
| | 55 | | private int currentAvatarSnapshotIndex; |
| | 56 | | private bool isLayoutDirty; |
| 2 | 57 | | private Vector2 lastScrollPosition = Vector2.one; |
| | 58 | | private Coroutine requireMoreEntriesRoutine; |
| | 59 | | private float loadMoreEntriesRestrictionTime; |
| | 60 | |
|
| 0 | 61 | | public Dictionary<string, FriendRequestEntry> Entries => entries; |
| | 62 | |
|
| 0 | 63 | | public int Count => Entries.Count + creationQueue.Keys.Count(s => !Entries.ContainsKey(s)); |
| | 64 | |
|
| 0 | 65 | | public int ReceivedCount => receivedRequestsList.Count() + |
| 0 | 66 | | creationQueue.Count(pair => pair.Value.isReceived && !Entries.ContainsKey(pair.Key)); |
| 0 | 67 | | public int SentCount => sentRequestsList.Count() + |
| 0 | 68 | | creationQueue.Count(pair => !pair.Value.isReceived && !Entries.ContainsKey(pair.Key)); |
| | 69 | |
|
| | 70 | | public event Action<FriendRequestEntryModel> OnCancelConfirmation; |
| | 71 | | public event Action<FriendRequestEntryModel> OnRejectConfirmation; |
| | 72 | | public event Action<FriendRequestEntryModel> OnFriendRequestApproved; |
| | 73 | | public event Action<string> OnFriendRequestSent; |
| | 74 | | public event Action<string> OnFriendRequestOpened; |
| | 75 | | public event Action OnRequireMoreEntries; |
| | 76 | |
|
| | 77 | | public override void OnEnable() |
| | 78 | | { |
| 0 | 79 | | base.OnEnable(); |
| 0 | 80 | | searchBar.Configure(new SearchBarComponentModel {placeHolderText = "Search a friend you want to add"}); |
| 0 | 81 | | searchBar.OnSubmit += SendFriendRequest; |
| 0 | 82 | | searchBar.OnSearchText += OnSearchInputValueChanged; |
| 0 | 83 | | contextMenuPanel.OnBlock += HandleFriendBlockRequest; |
| 0 | 84 | | scroll.onValueChanged.AddListener(RequestMoreEntries); |
| 0 | 85 | | UpdateLayout(); |
| 0 | 86 | | } |
| | 87 | |
|
| | 88 | | public override void OnDisable() |
| | 89 | | { |
| 0 | 90 | | base.OnDisable(); |
| 0 | 91 | | searchBar.OnSubmit -= SendFriendRequest; |
| 0 | 92 | | searchBar.OnSearchText -= OnSearchInputValueChanged; |
| 0 | 93 | | contextMenuPanel.OnBlock -= HandleFriendBlockRequest; |
| 0 | 94 | | scroll.onValueChanged.RemoveListener(RequestMoreEntries); |
| 0 | 95 | | NotificationsController.i?.DismissAllNotifications(NOTIFICATIONS_ID); |
| 0 | 96 | | } |
| | 97 | |
|
| | 98 | | public void Update() |
| | 99 | | { |
| 0 | 100 | | if (isLayoutDirty) |
| 0 | 101 | | Utils.ForceRebuildLayoutImmediate((RectTransform) filledStateContainer.transform); |
| 0 | 102 | | isLayoutDirty = false; |
| | 103 | |
|
| 0 | 104 | | SetQueuedEntries(); |
| 0 | 105 | | FetchProfilePicturesForVisibleEntries(); |
| 0 | 106 | | } |
| | 107 | |
|
| | 108 | | public void Expand() |
| | 109 | | { |
| 1 | 110 | | receivedRequestsList.Expand(); |
| 1 | 111 | | sentRequestsList.Expand(); |
| 1 | 112 | | } |
| | 113 | |
|
| | 114 | | public void Show() |
| | 115 | | { |
| 0 | 116 | | gameObject.SetActive(true); |
| 0 | 117 | | enabledHeader.SetActive(true); |
| 0 | 118 | | disabledHeader.SetActive(false); |
| 0 | 119 | | searchBar.ClearSearch(); |
| 0 | 120 | | } |
| | 121 | |
|
| | 122 | | public void Hide() |
| | 123 | | { |
| 0 | 124 | | gameObject.SetActive(false); |
| 0 | 125 | | enabledHeader.SetActive(false); |
| 0 | 126 | | disabledHeader.SetActive(true); |
| 0 | 127 | | contextMenuPanel.Hide(); |
| 0 | 128 | | } |
| | 129 | |
|
| | 130 | | public override void RefreshControl() |
| | 131 | | { |
| 0 | 132 | | Clear(); |
| | 133 | |
|
| 0 | 134 | | foreach (var friend in model.friends) |
| 0 | 135 | | Set(friend.userId, friend.model); |
| | 136 | |
|
| 0 | 137 | | if (model.isReceivedRequestsExpanded) |
| 0 | 138 | | receivedRequestsList.Expand(); |
| | 139 | | else |
| 0 | 140 | | receivedRequestsList.Collapse(); |
| | 141 | |
|
| 0 | 142 | | if (model.isSentRequestsExpanded) |
| 0 | 143 | | sentRequestsList.Expand(); |
| | 144 | | else |
| 0 | 145 | | sentRequestsList.Collapse(); |
| 0 | 146 | | } |
| | 147 | |
|
| | 148 | | public void Remove(string userId) |
| | 149 | | { |
| 0 | 150 | | if (creationQueue.ContainsKey(userId)) |
| 0 | 151 | | creationQueue.Remove(userId); |
| | 152 | |
|
| 0 | 153 | | if (!entries.ContainsKey(userId)) return; |
| | 154 | |
|
| 0 | 155 | | if (pooleableEntries.TryGetValue(userId, out var pooleableObject)) |
| | 156 | | { |
| 0 | 157 | | entryPool.Release(pooleableObject); |
| 0 | 158 | | pooleableEntries.Remove(userId); |
| | 159 | | } |
| | 160 | |
|
| 0 | 161 | | entries.Remove(userId); |
| 0 | 162 | | receivedRequestsList.Remove(userId); |
| 0 | 163 | | sentRequestsList.Remove(userId); |
| | 164 | |
|
| 0 | 165 | | UpdateEmptyOrFilledState(); |
| 0 | 166 | | UpdateCounterLabel(); |
| 0 | 167 | | UpdateLayout(); |
| 0 | 168 | | } |
| | 169 | |
|
| | 170 | | public void Clear() |
| | 171 | | { |
| 1 | 172 | | HideMoreFriendsLoadingSpinner(); |
| 1 | 173 | | loadMoreEntriesRestrictionTime = Time.realtimeSinceStartup; |
| 1 | 174 | | scroll.verticalNormalizedPosition = 1f; |
| 1 | 175 | | creationQueue.Clear(); |
| 1 | 176 | | entries.ToList().ForEach(pair => Remove(pair.Key)); |
| 1 | 177 | | receivedRequestsList.Clear(); |
| 1 | 178 | | sentRequestsList.Clear(); |
| 1 | 179 | | UpdateEmptyOrFilledState(); |
| 1 | 180 | | UpdateCounterLabel(); |
| 1 | 181 | | } |
| | 182 | |
|
| 0 | 183 | | public FriendRequestEntry Get(string userId) => entries.ContainsKey(userId) ? entries[userId] : null; |
| | 184 | |
|
| 0 | 185 | | public void Enqueue(string userId, FriendRequestEntryModel model) => creationQueue[userId] = model; |
| | 186 | |
|
| | 187 | | public void Set(string userId, FriendRequestEntryModel model) |
| | 188 | | { |
| 0 | 189 | | if (creationQueue.ContainsKey(userId)) |
| | 190 | | { |
| 0 | 191 | | creationQueue[userId] = model; |
| 0 | 192 | | return; |
| | 193 | | } |
| | 194 | |
|
| 0 | 195 | | if (!entries.ContainsKey(userId)) |
| | 196 | | { |
| 0 | 197 | | CreateEntry(userId); |
| 0 | 198 | | UpdateLayout(); |
| | 199 | | } |
| | 200 | |
|
| 0 | 201 | | Populate(userId, model); |
| 0 | 202 | | UpdateEmptyOrFilledState(); |
| 0 | 203 | | UpdateCounterLabel(); |
| 0 | 204 | | } |
| | 205 | |
|
| | 206 | | public void Populate(string userId, FriendRequestEntryModel model) |
| | 207 | | { |
| 0 | 208 | | if (!entries.ContainsKey(userId)) |
| | 209 | | { |
| 0 | 210 | | if (creationQueue.ContainsKey(userId)) |
| 0 | 211 | | creationQueue[userId] = model; |
| 0 | 212 | | return; |
| | 213 | | } |
| | 214 | |
|
| 0 | 215 | | var entry = entries[userId]; |
| 0 | 216 | | entry.Populate(model); |
| | 217 | |
|
| 0 | 218 | | if (model.isReceived) |
| 0 | 219 | | receivedRequestsList.Add(userId, entry); |
| | 220 | | else |
| 0 | 221 | | sentRequestsList.Add(userId, entry); |
| 0 | 222 | | } |
| | 223 | |
|
| | 224 | | public void ShowUserNotFoundNotification() |
| | 225 | | { |
| 0 | 226 | | friendSearchFailedNotification.model.timer = NOTIFICATIONS_DURATION; |
| 0 | 227 | | friendSearchFailedNotification.model.groupID = NOTIFICATIONS_ID; |
| 0 | 228 | | NotificationsController.i?.ShowNotification(friendSearchFailedNotification); |
| 0 | 229 | | } |
| | 230 | |
|
| 1 | 231 | | private void UpdateLayout() => isLayoutDirty = true; |
| | 232 | |
|
| | 233 | | private void CreateEntry(string userId) |
| | 234 | | { |
| 0 | 235 | | entryPool = GetEntryPool(); |
| 0 | 236 | | var newFriendEntry = entryPool.Get(); |
| 0 | 237 | | pooleableEntries.Add(userId, newFriendEntry); |
| 0 | 238 | | var entry = newFriendEntry.gameObject.GetComponent<FriendRequestEntry>(); |
| 0 | 239 | | if (entry == null) return; |
| 0 | 240 | | entries.Add(userId, entry); |
| | 241 | |
|
| 0 | 242 | | entry.OnAccepted -= OnFriendRequestReceivedAccepted; |
| 0 | 243 | | entry.OnAccepted += OnFriendRequestReceivedAccepted; |
| 0 | 244 | | entry.OnRejected -= OnEntryRejectButtonPressed; |
| 0 | 245 | | entry.OnRejected += OnEntryRejectButtonPressed; |
| 0 | 246 | | entry.OnCancelled -= OnEntryCancelButtonPressed; |
| 0 | 247 | | entry.OnCancelled += OnEntryCancelButtonPressed; |
| 0 | 248 | | entry.OnMenuToggle -= OnEntryMenuToggle; |
| 0 | 249 | | entry.OnMenuToggle += OnEntryMenuToggle; |
| 0 | 250 | | entry.OnOpened -= OpenFriendRequestDetails; |
| 0 | 251 | | entry.OnOpened += OpenFriendRequestDetails; |
| 0 | 252 | | } |
| | 253 | |
|
| | 254 | | private Pool GetEntryPool() |
| | 255 | | { |
| 0 | 256 | | var entryPool = PoolManager.i.GetPool(FRIEND_ENTRIES_POOL_NAME_PREFIX + name + GetInstanceID()); |
| 0 | 257 | | if (entryPool != null) return entryPool; |
| | 258 | |
|
| 0 | 259 | | entryPool = PoolManager.i.AddPool( |
| | 260 | | FRIEND_ENTRIES_POOL_NAME_PREFIX + name + GetInstanceID(), |
| | 261 | | Instantiate(entryPrefab).gameObject, |
| | 262 | | maxPrewarmCount: PRE_INSTANTIATED_ENTRIES, |
| | 263 | | isPersistent: true); |
| 0 | 264 | | entryPool.ForcePrewarm(); |
| | 265 | |
|
| 0 | 266 | | return entryPool; |
| | 267 | | } |
| | 268 | |
|
| | 269 | | private void SendFriendRequest(string friendUserName) |
| | 270 | | { |
| 0 | 271 | | friendUserName = friendUserName.Trim() |
| | 272 | | .Replace("\n", "") |
| | 273 | | .Replace("\r", ""); |
| 0 | 274 | | if (string.IsNullOrEmpty(friendUserName)) return; |
| | 275 | |
|
| 0 | 276 | | searchBar.ClearSearch(); |
| 0 | 277 | | lastRequestSentUserName = friendUserName; |
| 0 | 278 | | OnFriendRequestSent?.Invoke(friendUserName); |
| 0 | 279 | | } |
| | 280 | |
|
| | 281 | | public void ShowAlreadyFriendsNotification() |
| | 282 | | { |
| 0 | 283 | | alreadyFriendsNotification.model.timer = NOTIFICATIONS_DURATION; |
| 0 | 284 | | alreadyFriendsNotification.model.groupID = NOTIFICATIONS_ID; |
| 0 | 285 | | NotificationsController.i?.ShowNotification(alreadyFriendsNotification); |
| 0 | 286 | | } |
| | 287 | |
|
| | 288 | | public void ShowRequestSuccessfullySentNotification() |
| | 289 | | { |
| 0 | 290 | | requestSentNotification.model.timer = NOTIFICATIONS_DURATION; |
| 0 | 291 | | requestSentNotification.model.groupID = NOTIFICATIONS_ID; |
| 0 | 292 | | requestSentNotification.model.message = $"Your request to {lastRequestSentUserName} successfully sent!"; |
| 0 | 293 | | NotificationsController.i?.ShowNotification(requestSentNotification); |
| 0 | 294 | | } |
| | 295 | |
|
| | 296 | | public void HideMoreFriendsToLoadHint() |
| | 297 | | { |
| 1 | 298 | | loadMoreEntriesContainer.SetActive(false); |
| 1 | 299 | | UpdateLayout(); |
| 1 | 300 | | } |
| | 301 | |
|
| | 302 | | public void ShowMoreEntriesToLoadHint(int hiddenCount) |
| | 303 | | { |
| 0 | 304 | | loadMoreEntriesLabel.text = $"{hiddenCount} requests hidden. Scroll down to show more."; |
| 0 | 305 | | loadMoreEntriesContainer.SetActive(true); |
| 0 | 306 | | UpdateLayout(); |
| 0 | 307 | | } |
| | 308 | |
|
| 0 | 309 | | private void ShowMoreFriendsLoadingSpinner() => loadMoreEntriesSpinner.SetActive(true); |
| | 310 | |
|
| 1 | 311 | | private void HideMoreFriendsLoadingSpinner() => loadMoreEntriesSpinner.SetActive(false); |
| | 312 | |
|
| | 313 | | private void UpdateEmptyOrFilledState() |
| | 314 | | { |
| 1 | 315 | | emptyStateContainer.SetActive(entries.Count == 0); |
| 1 | 316 | | filledStateContainer.SetActive(entries.Count > 0); |
| 1 | 317 | | } |
| | 318 | |
|
| | 319 | | private void OnSearchInputValueChanged(string friendUserName) |
| | 320 | | { |
| 0 | 321 | | if (!string.IsNullOrEmpty(friendUserName)) |
| 0 | 322 | | NotificationsController.i?.DismissAllNotifications(NOTIFICATIONS_ID); |
| 0 | 323 | | } |
| | 324 | |
|
| | 325 | | private void OpenFriendRequestDetails(FriendRequestEntry entry) => |
| 0 | 326 | | OnFriendRequestOpened?.Invoke(entry.Model.userId); |
| | 327 | |
|
| | 328 | | private void OnFriendRequestReceivedAccepted(FriendRequestEntry requestEntry) |
| | 329 | | { |
| 0 | 330 | | ShowFriendAcceptedNotification(requestEntry); |
| 0 | 331 | | Remove(requestEntry.Model.userId); |
| 0 | 332 | | OnFriendRequestApproved?.Invoke((FriendRequestEntryModel) requestEntry.Model); |
| 0 | 333 | | } |
| | 334 | |
|
| | 335 | | private void ShowFriendAcceptedNotification(FriendRequestEntry requestEntry) |
| | 336 | | { |
| 0 | 337 | | acceptedFriendNotification.model.timer = NOTIFICATIONS_DURATION; |
| 0 | 338 | | acceptedFriendNotification.model.groupID = NOTIFICATIONS_ID; |
| 0 | 339 | | acceptedFriendNotification.model.message = $"You and {requestEntry.Model.userName} are now friends!"; |
| 0 | 340 | | NotificationsController.i?.ShowNotification(acceptedFriendNotification); |
| 0 | 341 | | } |
| | 342 | |
|
| | 343 | | private void OnEntryRejectButtonPressed(FriendRequestEntry requestEntry) |
| | 344 | | { |
| 0 | 345 | | Remove(requestEntry.Model.userId); |
| 0 | 346 | | OnRejectConfirmation?.Invoke((FriendRequestEntryModel) requestEntry.Model); |
| 0 | 347 | | } |
| | 348 | |
|
| | 349 | | private void OnEntryCancelButtonPressed(FriendRequestEntry requestEntry) |
| | 350 | | { |
| 0 | 351 | | Remove(requestEntry.Model.userId); |
| 0 | 352 | | OnCancelConfirmation?.Invoke((FriendRequestEntryModel) requestEntry.Model); |
| 0 | 353 | | } |
| | 354 | |
|
| | 355 | | private void OnEntryMenuToggle(FriendEntryBase friendEntry) |
| | 356 | | { |
| 0 | 357 | | friendEntry.Dock(contextMenuPanel); |
| 0 | 358 | | contextMenuPanel.Show(friendEntry.Model.userId); |
| 0 | 359 | | contextMenuPanel.SetFriendshipContentActive(false); |
| 0 | 360 | | } |
| | 361 | |
|
| | 362 | | private void UpdateCounterLabel() |
| | 363 | | { |
| 1 | 364 | | receivedRequestsCountText.SetText("RECEIVED ({0})", receivedRequestsList.Count()); |
| 1 | 365 | | sentRequestsCountText.SetText("SENT ({0})", sentRequestsList.Count()); |
| 1 | 366 | | } |
| | 367 | |
|
| | 368 | | private void HandleFriendBlockRequest(string userId, bool blockUser) |
| | 369 | | { |
| 0 | 370 | | var friendEntryToBlock = Get(userId); |
| 0 | 371 | | if (friendEntryToBlock == null) return; |
| | 372 | | // instantly refresh ui |
| 0 | 373 | | friendEntryToBlock.Model.blocked = blockUser; |
| 0 | 374 | | Set(userId, (FriendRequestEntryModel) friendEntryToBlock.Model); |
| 0 | 375 | | } |
| | 376 | |
|
| | 377 | | private void FetchProfilePicturesForVisibleEntries() |
| | 378 | | { |
| 0 | 379 | | foreach (var entry in entries.Values.Skip(currentAvatarSnapshotIndex).Take(AVATAR_SNAPSHOTS_PER_FRAME)) |
| | 380 | | { |
| 0 | 381 | | if (entry.IsVisible(viewport)) |
| 0 | 382 | | entry.EnableAvatarSnapshotFetching(); |
| | 383 | | else |
| 0 | 384 | | entry.DisableAvatarSnapshotFetching(); |
| | 385 | | } |
| | 386 | |
|
| 0 | 387 | | currentAvatarSnapshotIndex += AVATAR_SNAPSHOTS_PER_FRAME; |
| | 388 | |
|
| 0 | 389 | | if (currentAvatarSnapshotIndex >= entries.Count) |
| 0 | 390 | | currentAvatarSnapshotIndex = 0; |
| 0 | 391 | | } |
| | 392 | |
|
| | 393 | | private void SetQueuedEntries() |
| | 394 | | { |
| 0 | 395 | | if (creationQueue.Count == 0) return; |
| | 396 | |
|
| 0 | 397 | | for (var i = 0; i < CREATION_AMOUNT_PER_FRAME && creationQueue.Count != 0; i++) |
| | 398 | | { |
| 0 | 399 | | var pair = creationQueue.FirstOrDefault(); |
| 0 | 400 | | creationQueue.Remove(pair.Key); |
| 0 | 401 | | Set(pair.Key, pair.Value); |
| | 402 | | } |
| | 403 | |
|
| 0 | 404 | | HideMoreFriendsLoadingSpinner(); |
| 0 | 405 | | } |
| | 406 | |
|
| | 407 | | private void RequestMoreEntries(Vector2 position) |
| | 408 | | { |
| 0 | 409 | | if (!loadMoreEntriesContainer.activeInHierarchy || |
| | 410 | | loadMoreEntriesSpinner.activeInHierarchy || |
| 0 | 411 | | (Time.realtimeSinceStartup - loadMoreEntriesRestrictionTime) < MIN_TIME_TO_REQUIRE_MORE_ENTRIES) return; |
| | 412 | |
|
| 0 | 413 | | if (position.y < REQUEST_MORE_ENTRIES_SCROLL_THRESHOLD && lastScrollPosition.y >= REQUEST_MORE_ENTRIES_SCROLL_TH |
| | 414 | | { |
| 0 | 415 | | if (requireMoreEntriesRoutine != null) |
| 0 | 416 | | StopCoroutine(requireMoreEntriesRoutine); |
| | 417 | |
|
| 0 | 418 | | ShowMoreFriendsLoadingSpinner(); |
| 0 | 419 | | requireMoreEntriesRoutine = StartCoroutine(WaitThenRequireMoreEntries()); |
| | 420 | |
|
| 0 | 421 | | loadMoreEntriesRestrictionTime = Time.realtimeSinceStartup; |
| | 422 | | } |
| | 423 | |
|
| 0 | 424 | | lastScrollPosition = position; |
| 0 | 425 | | } |
| | 426 | |
|
| | 427 | | private IEnumerator WaitThenRequireMoreEntries() |
| | 428 | | { |
| 0 | 429 | | yield return new WaitForSeconds(1f); |
| 0 | 430 | | OnRequireMoreEntries?.Invoke(); |
| 0 | 431 | | } |
| | 432 | |
|
| | 433 | | [Serializable] |
| | 434 | | private class Model |
| | 435 | | { |
| | 436 | | [Serializable] |
| | 437 | | public struct UserIdAndEntry |
| | 438 | | { |
| | 439 | | public string userId; |
| | 440 | | public bool received; |
| | 441 | | public SerializableEntryModel model; |
| | 442 | | } |
| | 443 | |
|
| | 444 | | [Serializable] |
| | 445 | | public class SerializableEntryModel : FriendRequestEntryModel |
| | 446 | | { |
| | 447 | | } |
| | 448 | |
|
| | 449 | | public UserIdAndEntry[] friends; |
| 2 | 450 | | public bool isReceivedRequestsExpanded = true; |
| 2 | 451 | | public bool isSentRequestsExpanded = true; |
| | 452 | | } |
| | 453 | | } |