From 2435c60039060a75e80ff452a388d671bc8f05cd Mon Sep 17 00:00:00 2001 From: Bojan Mojsilovic Date: Tue, 3 Oct 2023 17:15:19 +0200 Subject: [PATCH] Fix profile header flicker on load --- src/contexts/ProfileContext.tsx | 7 + src/pages/Profile.module.scss | 7 + src/pages/Profile.tsx | 272 +++++++++++++++++--------------- 3 files changed, 156 insertions(+), 130 deletions(-) diff --git a/src/contexts/ProfileContext.tsx b/src/contexts/ProfileContext.tsx index e5b585d3..0c254f3a 100644 --- a/src/contexts/ProfileContext.tsx +++ b/src/contexts/ProfileContext.tsx @@ -123,6 +123,7 @@ export type ProfileContextStore = { addContact: (pubkey: string, source: PrimalUser[]) => void, fetchZapList: (pubkey: string | undefined) => void, fetchNextZapsPage: () => void, + resetProfile: () => void, } } @@ -877,6 +878,11 @@ export const ProfileProvider = (props: { children: ContextChildren }) => { } } + const resetProfile = () => { + updateStore('userProfile', () => undefined); + updateStore('userStats', () => ({ ...emptyStats })); + }; + const refreshNotes = () => { }; @@ -1120,6 +1126,7 @@ export const ProfileProvider = (props: { children: ContextChildren }) => { fetchZapList, fetchNextZapsPage, clearZaps, + resetProfile, }, }); diff --git a/src/pages/Profile.module.scss b/src/pages/Profile.module.scss index 95d86cf4..6ad78aaa 100644 --- a/src/pages/Profile.module.scss +++ b/src/pages/Profile.module.scss @@ -5,6 +5,13 @@ // min-height: 474px; } +.emptyHeader { + position: relative; + background-color: var(--background-card); + padding-bottom: 4px; + height: 540px; +} + .banner { width: 100%; height: 214px; diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 383b5239..4472c68a 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -7,6 +7,8 @@ import { createSignal, For, Match, + onCleanup, + onMount, Resource, Show, Switch @@ -98,6 +100,10 @@ const Profile: Component = () => { profile?.actions.clearZaps(); } + onCleanup(() => { + profile?.actions.resetProfile(); + }) + createEffect(() => { if (account?.isKeyLookupDone) { setProfile(getHex()); @@ -456,159 +462,165 @@ const Profile: Component = () => { -
-
-
} - > - - -
+ } + > - -
-
-
- -
+
+
+
} + > + + +
-
- + +
+
+
+ +
+ +
+ +
-
- + -
-
- -
-
- - +
+
+ +
+
+ + + +
+ + + +
+
-
- - -
-
-
+ + navigate(`/messages/${profile?.userProfile?.npub}`)} + > +
+
+
- - navigate(`/messages/${profile?.userProfile?.npub}`)} - > -
-
-
+ - + + navigate('/settings/profile')} + title={intl.formatMessage(tActions.editProfile)} + > +
{intl.formatMessage(tActions.editProfile)}
+
+
+
- - navigate('/settings/profile')} - title={intl.formatMessage(tActions.editProfile)} - > -
{intl.formatMessage(tActions.editProfile)}
-
-
-
+
+ +
+
+ {profileName()} + +
+
+ +
+ {intl.formatMessage(t.followsYou)} +
+
-
- -
-
- {profileName()} - -
-
- -
- {intl.formatMessage(t.followsYou)} +
+ + +
+ {intl.formatMessage( + t.jointDate, + { + date: shortDate(profile?.userStats.time_joined), + }, + )}
-
- -
- {intl.formatMessage( - t.jointDate, - { - date: shortDate(profile?.userStats.time_joined), - }, - )} -
-
-
- -
- -
-
{nip05Verification(profile?.userProfile)}
+
+ +
+
{nip05Verification(profile?.userProfile)}
+
+
+
+
- -
-
-
- - -
- 0}> -
+
-
+ + 0}> +
+
+
- - - - - - { - doReportUser(); - setConfirmReportUser(false); - }} - onAbort={() => setConfirmReportUser(false)} - /> + +
- { - doMuteUser(); - setConfirmMuteUser(false); - }} - onAbort={() => setConfirmMuteUser(false)} - /> + + + { + doReportUser(); + setConfirmReportUser(false); + }} + onAbort={() => setConfirmReportUser(false)} + /> + + { + doMuteUser(); + setConfirmMuteUser(false); + }} + onAbort={() => setConfirmMuteUser(false)} + /> +
) }