From 9278822088d212c9bee6a40a6a8b773bc482242d Mon Sep 17 00:00:00 2001 From: Patroll <6214736+P4tr0ll@users.noreply.github.com> Date: Wed, 4 Oct 2023 19:31:43 +0200 Subject: Fix invite codes flash on desktop, use loading placeholder (#1591) * Fix invite codes flashing untrue value before loaded * Add loading placeholder for right nav invites --- src/state/models/me.ts | 8 +++-- src/view/com/modals/InviteCodes.tsx | 27 ++++++++++++++ src/view/screens/Settings.tsx | 70 ++++++++++++++++++++---------------- src/view/shell/Drawer.tsx | 54 ++++++++++++++-------------- src/view/shell/desktop/RightNav.tsx | 72 ++++++++++++++++++++++--------------- 5 files changed, 142 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/state/models/me.ts b/src/state/models/me.ts index 186e61cf6..8a7a4c851 100644 --- a/src/state/models/me.ts +++ b/src/state/models/me.ts @@ -25,13 +25,13 @@ export class MeModel { savedFeeds: SavedFeedsModel notifications: NotificationsFeedModel follows: MyFollowsCache - invites: ComAtprotoServerDefs.InviteCode[] = [] + invites: ComAtprotoServerDefs.InviteCode[] | null = [] appPasswords: ComAtprotoServerListAppPasswords.AppPassword[] = [] lastProfileStateUpdate = Date.now() lastNotifsUpdate = Date.now() get invitesAvailable() { - return this.invites.filter(isInviteAvailable).length + return this.invites?.filter(isInviteAvailable).length || null } constructor(public rootStore: RootStoreModel) { @@ -180,7 +180,9 @@ export class MeModel { } catch (e) { this.rootStore.log.error('Failed to fetch user invite codes', e) } - await this.rootStore.invitedUsers.fetch(this.invites) + if (this.invites) { + await this.rootStore.invitedUsers.fetch(this.invites) + } } } diff --git a/src/view/com/modals/InviteCodes.tsx b/src/view/com/modals/InviteCodes.tsx index 09cfd4de7..0cb0c56aa 100644 --- a/src/view/com/modals/InviteCodes.tsx +++ b/src/view/com/modals/InviteCodes.tsx @@ -26,6 +26,33 @@ export function Component({}: {}) { store.shell.closeModal() }, [store]) + if (store.me.invites === null) { + return ( + + + Error + + + An error occurred while loading invite codes. + + + +