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