From f18b9b32b0d296c8d19dc06956699f95c0af9be2 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 21 Nov 2023 10:57:34 -0600 Subject: PWI Base (#1964) * Base work for public view * Make default moderation settings more restrictive * Fix type * Handle showing sign-in on authed actions * Fix hoc logic * Simplify prefs logic * Remove duplicate method * Add todo * Clean up RepostButton.web * Fix x button color * Add todo * Retain existing label prefs for now, use separate logged out settings * Clean up useAuthedMethod, rename to useRequireAuth * Add todos * Move dismiss logic to withAuthRequired * Ooops add web * Block public view in prod * Add todo * Fix bad import --- src/view/screens/Profile.tsx | 131 ++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 64 deletions(-) (limited to 'src/view/screens/Profile.tsx') diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index 88b11b114..5411bc044 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -43,82 +43,85 @@ interface SectionRef { } type Props = NativeStackScreenProps -export const ProfileScreen = withAuthRequired(function ProfileScreenImpl({ - route, -}: Props) { - const {currentAccount} = useSession() - const name = - route.params.name === 'me' ? currentAccount?.did : route.params.name - const moderationOpts = useModerationOpts() - const { - data: resolvedDid, - error: resolveError, - refetch: refetchDid, - isFetching: isFetchingDid, - } = useResolveDidQuery(name) - const { - data: profile, - dataUpdatedAt, - error: profileError, - refetch: refetchProfile, - isFetching: isFetchingProfile, - } = useProfileQuery({ - did: resolvedDid?.did, - }) +export const ProfileScreen = withAuthRequired( + function ProfileScreenImpl({route}: Props) { + const {currentAccount} = useSession() + const name = + route.params.name === 'me' ? currentAccount?.did : route.params.name + const moderationOpts = useModerationOpts() + const { + data: resolvedDid, + error: resolveError, + refetch: refetchDid, + isFetching: isFetchingDid, + } = useResolveDidQuery(name) + const { + data: profile, + dataUpdatedAt, + error: profileError, + refetch: refetchProfile, + isFetching: isFetchingProfile, + } = useProfileQuery({ + did: resolvedDid?.did, + }) - const onPressTryAgain = React.useCallback(() => { - if (resolveError) { - refetchDid() - } else { - refetchProfile() - } - }, [resolveError, refetchDid, refetchProfile]) + const onPressTryAgain = React.useCallback(() => { + if (resolveError) { + refetchDid() + } else { + refetchProfile() + } + }, [resolveError, refetchDid, refetchProfile]) - if (isFetchingDid || isFetchingProfile || !moderationOpts) { - return ( - - + + + ) + } + if (resolveError || profileError) { + return ( + + + + ) + } + if (profile && moderationOpts) { + return ( + - - ) - } - if (resolveError || profileError) { + ) + } + // should never happen return ( ) - } - if (profile && moderationOpts) { - return ( - - ) - } - // should never happen - return ( - - - - ) -}) + }, + { + isPublic: true, + }, +) function ProfileScreenLoaded({ profile: profileUnshadowed, -- cgit 1.4.1