From 95f8bd8ddb356ce982b31eabb2dcf9f08ba40b9b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 22 Nov 2023 16:53:11 -0600 Subject: [PATCH] [PWI] Misc (#1977) * PostDropdownBtn * Hide reply prompt * Hide FABs --- src/view/com/feeds/FeedPage.tsx | 60 +++++++++++++-------- src/view/com/post-thread/PostThread.tsx | 5 +- src/view/com/util/forms/PostDropdownBtn.tsx | 41 +++++++------- src/view/screens/Feeds.tsx | 18 ++++--- src/view/screens/Profile.tsx | 20 +++---- src/view/screens/ProfileFeed.tsx | 26 +++++---- 6 files changed, 99 insertions(+), 71 deletions(-) diff --git a/src/view/com/feeds/FeedPage.tsx b/src/view/com/feeds/FeedPage.tsx index e7dcf09b..535306af 100644 --- a/src/view/com/feeds/FeedPage.tsx +++ b/src/view/com/feeds/FeedPage.tsx @@ -41,7 +41,7 @@ export function FeedPage({ renderEmptyState: () => JSX.Element renderEndOfFeed?: () => JSX.Element }) { - const {isSandbox} = useSession() + const {isSandbox, hasSession} = useSession() const pal = usePalette('default') const {_} = useLingui() const {isDesktop} = useWebMediaQueries() @@ -123,24 +123,35 @@ export function FeedPage({ } onPress={emitSoftReset} /> - - } - /> + {hasSession && ( + + } + /> + )} ) } return <> - }, [isDesktop, pal.view, pal.text, pal.textLight, hasNew, _, isSandbox]) + }, [ + isDesktop, + pal.view, + pal.text, + pal.textLight, + hasNew, + _, + isSandbox, + hasSession, + ]) return ( @@ -166,14 +177,17 @@ export function FeedPage({ showIndicator={hasNew} /> )} - } - accessibilityRole="button" - accessibilityLabel={_(msg`New post`)} - accessibilityHint="" - /> + + {hasSession && ( + } + accessibilityRole="button" + accessibilityLabel={_(msg`New post`)} + accessibilityHint="" + /> + )} ) } diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 55448fcc..c1983394 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -38,6 +38,7 @@ import { UsePreferencesQueryResponse, usePreferencesQuery, } from '#/state/queries/preferences' +import {useSession} from '#/state/session' // const MAINTAIN_VISIBLE_CONTENT_POSITION = {minIndexForVisible: 2} TODO @@ -130,6 +131,7 @@ function PostThreadLoaded({ onRefresh: () => void onPressReply: () => void }) { + const {hasSession} = useSession() const {_} = useLingui() const pal = usePalette('default') const {isTablet, isDesktop} = useWebMediaQueries() @@ -223,7 +225,7 @@ function PostThreadLoaded({ ) - } else if (item === REPLY_PROMPT) { + } else if (item === REPLY_PROMPT && hasSession) { return ( {isDesktop && } @@ -305,6 +307,7 @@ function PostThreadLoaded({ return null }, [ + hasSession, isTablet, isDesktop, onPressReply, diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index 889839d0..636817f7 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -35,7 +35,7 @@ export function PostDropdownBtn({ record: AppBskyFeedPost.Record style?: StyleProp }) { - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const theme = useTheme() const {_} = useLingui() const defaultCtrlColor = theme.palette.default.postCtrl @@ -136,10 +136,10 @@ export function PostDropdownBtn({ web: 'share', }, }, - { + hasSession && { label: 'separator', }, - { + hasSession && { label: isThreadMuted ? _(msg`Unmute thread`) : _(msg`Mute thread`), onPress() { onToggleThreadMute() @@ -153,27 +153,28 @@ export function PostDropdownBtn({ web: 'comment-slash', }, }, - { + hasSession && { label: 'separator', }, - !isAuthor && { - label: _(msg`Report post`), - onPress() { - openModal({ - name: 'report', - uri: post.uri, - cid: post.cid, - }) - }, - testID: 'postDropdownReportBtn', - icon: { - ios: { - name: 'exclamationmark.triangle', + !isAuthor && + hasSession && { + label: _(msg`Report post`), + onPress() { + openModal({ + name: 'report', + uri: post.uri, + cid: post.cid, + }) + }, + testID: 'postDropdownReportBtn', + icon: { + ios: { + name: 'exclamationmark.triangle', + }, + android: 'ic_menu_report_image', + web: 'circle-exclamation', }, - android: 'ic_menu_report_image', - web: 'circle-exclamation', }, - }, isAuthor && { label: 'separator', }, diff --git a/src/view/screens/Feeds.tsx b/src/view/screens/Feeds.tsx index 28433911..f8fc0db1 100644 --- a/src/view/screens/Feeds.tsx +++ b/src/view/screens/Feeds.tsx @@ -504,14 +504,16 @@ export const FeedsScreen = withAuthRequired( desktopFixedHeight /> - } - accessibilityRole="button" - accessibilityLabel={_(msg`New post`)} - accessibilityHint="" - /> + {hasSession && ( + } + accessibilityRole="button" + accessibilityLabel={_(msg`New post`)} + accessibilityHint="" + /> + )} ) }, diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index 1d03f280..55fe02cd 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -131,7 +131,7 @@ function ProfileScreenLoaded({ hideBackButton: boolean }) { const profile = useProfileShadow(profileUnshadowed) - const {currentAccount} = useSession() + const {hasSession, currentAccount} = useSession() const setMinimalShellMode = useSetMinimalShellMode() const {openComposer} = useComposerControls() const {screen, track} = useAnalytics() @@ -360,14 +360,16 @@ function ProfileScreenLoaded({ ) : null} - } - accessibilityRole="button" - accessibilityLabel={_(msg`New post`)} - accessibilityHint="" - /> + {hasSession && ( + } + accessibilityRole="button" + accessibilityLabel={_(msg`New post`)} + accessibilityHint="" + /> + )} ) } diff --git a/src/view/screens/ProfileFeed.tsx b/src/view/screens/ProfileFeed.tsx index 28a61bea..642793ed 100644 --- a/src/view/screens/ProfileFeed.tsx +++ b/src/view/screens/ProfileFeed.tsx @@ -423,16 +423,22 @@ export function ProfileFeedScreenInner({ /> )} - openComposer({})} - icon={ - - } - accessibilityRole="button" - accessibilityLabel={_(msg`New post`)} - accessibilityHint="" - /> + {hasSession && ( + openComposer({})} + icon={ + + } + accessibilityRole="button" + accessibilityLabel={_(msg`New post`)} + accessibilityHint="" + /> + )} ) }