Refactor minimal shell mode to refcounting (#10319)

This commit is contained in:
Samuel Newman
2026-04-21 13:04:02 -07:00
committed by GitHub
parent 6d53459e92
commit 3153ea4302
40 changed files with 152 additions and 393 deletions
+13 -2
View File
@@ -1,6 +1,11 @@
import {forwardRef, memo, useContext, useMemo} from 'react' import {forwardRef, memo, useContext, useMemo} from 'react'
import {StyleSheet, View, type ViewProps, type ViewStyle} from 'react-native' import {
import {type StyleProp} from 'react-native' type StyleProp,
StyleSheet,
View,
type ViewProps,
type ViewStyle,
} from 'react-native'
import { import {
KeyboardAwareScrollView, KeyboardAwareScrollView,
type KeyboardAwareScrollViewProps, type KeyboardAwareScrollViewProps,
@@ -11,6 +16,7 @@ import Animated, {
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useSafeAreaInsets} from 'react-native-safe-area-context'
import {useEnableMinimalShellModeForScreen} from '#/state/shell'
import {useShellLayout} from '#/state/shell/shell-layout' import {useShellLayout} from '#/state/shell/shell-layout'
import { import {
atoms as a, atoms as a,
@@ -30,6 +36,7 @@ export * as Header from '#/components/Layout/Header'
export type ScreenProps = React.ComponentProps<typeof View> & { export type ScreenProps = React.ComponentProps<typeof View> & {
style?: StyleProp<ViewStyle> style?: StyleProp<ViewStyle>
noInsetTop?: boolean noInsetTop?: boolean
minimalShell?: boolean
} }
/** /**
@@ -38,9 +45,13 @@ export type ScreenProps = React.ComponentProps<typeof View> & {
export const Screen = memo(function Screen({ export const Screen = memo(function Screen({
style, style,
noInsetTop, noInsetTop,
minimalShell = false,
...props ...props
}: ScreenProps) { }: ScreenProps) {
const {top} = useSafeAreaInsets() const {top} = useSafeAreaInsets()
useEnableMinimalShellModeForScreen({enabled: minimalShell})
return ( return (
<> <>
{IS_WEB && <WebCenterBorders />} {IS_WEB && <WebCenterBorders />}
+1 -4
View File
@@ -23,7 +23,6 @@ import {
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation' import {useBookmarkMutation} from '#/state/queries/bookmarks/useBookmarkMutation'
import {useBookmarksQuery} from '#/state/queries/bookmarks/useBookmarksQuery' import {useBookmarksQuery} from '#/state/queries/bookmarks/useBookmarksQuery'
import {useSetMinimalShellMode} from '#/state/shell'
import {Post} from '#/view/com/post/Post' import {Post} from '#/view/com/post/Post'
import {EmptyState} from '#/view/com/util/EmptyState' import {EmptyState} from '#/view/com/util/EmptyState'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
@@ -43,14 +42,12 @@ import {IS_IOS} from '#/env'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Bookmarks'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'Bookmarks'>
export function BookmarksScreen({}: Props) { export function BookmarksScreen({}: Props) {
const setMinimalShellMode = useSetMinimalShellMode()
const ax = useAnalytics() const ax = useAnalytics()
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setMinimalShellMode(false)
ax.metric('bookmarks:view', {}) ax.metric('bookmarks:view', {})
}, [setMinimalShellMode, ax]), }, [ax]),
) )
return ( return (
+3 -8
View File
@@ -1,4 +1,4 @@
import {useCallback, useLayoutEffect, useState} from 'react' import {useState} from 'react'
import {LayoutAnimationConfig} from 'react-native-reanimated' import {LayoutAnimationConfig} from 'react-native-reanimated'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
@@ -8,7 +8,7 @@ import {
type AllNavigatorParams, type AllNavigatorParams,
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {useSetMinimalShellMode} from '#/state/shell' import {useEnableMinimalShellMode} from '#/state/shell'
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
import {FindContactsFlow} from '#/components/contacts/FindContactsFlow' import {FindContactsFlow} from '#/components/contacts/FindContactsFlow'
import {useFindContactsFlowState} from '#/components/contacts/state' import {useFindContactsFlowState} from '#/components/contacts/state'
@@ -36,12 +36,7 @@ export function FindContactsFlowScreen({navigation}: Props) {
}) })
}) })
const setMinimalShellMode = useSetMinimalShellMode() useEnableMinimalShellMode()
const effect = useCallback(() => {
setMinimalShellMode(true)
return () => setMinimalShellMode(false)
}, [setMinimalShellMode])
useLayoutEffect(effect)
return ( return (
<Layout.Screen> <Layout.Screen>
+3 -16
View File
@@ -4,7 +4,6 @@ import {type AppBskyFeedDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {HITSLOP_10} from '#/lib/constants' import {HITSLOP_10} from '#/lib/constants'
@@ -17,7 +16,6 @@ import {sanitizeHandle} from '#/lib/strings/handles'
import {enforceLen} from '#/lib/strings/helpers' import {enforceLen} from '#/lib/strings/helpers'
import {useSearchPostsQuery} from '#/state/queries/search-posts' import {useSearchPostsQuery} from '#/state/queries/search-posts'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useCloseAllActiveElements} from '#/state/util' import {useCloseAllActiveElements} from '#/state/util'
import {Pager} from '#/view/com/pager/Pager' import {Pager} from '#/view/com/pager/Pager'
@@ -79,21 +77,10 @@ export default function HashtagScreen({
}, [tag, author]) }, [tag, author])
const [activeTab, setActiveTab] = useState(0) const [activeTab, setActiveTab] = useState(0)
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect( const onPageSelected = (index: number) => {
useCallback(() => { setActiveTab(index)
setMinimalShellMode(false) }
}, [setMinimalShellMode]),
)
const onPageSelected = useCallback(
(index: number) => {
setMinimalShellMode(false)
setActiveTab(index)
},
[setMinimalShellMode],
)
const sections = useMemo(() => { const sections = useMemo(() => {
return [ return [
+2 -10
View File
@@ -1,9 +1,8 @@
import {useCallback, useState} from 'react' import {useState} from 'react'
import {LayoutAnimation, Pressable, View} from 'react-native' import {LayoutAnimation, Pressable, View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo' import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
import { import {
@@ -11,7 +10,7 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {getEntries} from '#/logger/logDump' import {getEntries} from '#/logger/logDump'
import {useSetMinimalShellMode, useTickEveryMinute} from '#/state/shell' import {useTickEveryMinute} from '#/state/shell'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import { import {
ChevronBottom_Stroke2_Corner0_Rounded as ChevronBottomIcon, ChevronBottom_Stroke2_Corner0_Rounded as ChevronBottomIcon,
@@ -28,17 +27,10 @@ export function LogScreen({}: NativeStackScreenProps<
>) { >) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const [expanded, setExpanded] = useState<string[]>([]) const [expanded, setExpanded] = useState<string[]>([])
const timeAgo = useGetTimeAgo() const timeAgo = useGetTimeAgo()
const tick = useTickEveryMinute() const tick = useTickEveryMinute()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const toggler = (id: string) => () => { const toggler = (id: string) => () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
if (expanded.includes(id)) { if (expanded.includes(id)) {
+2 -6
View File
@@ -30,7 +30,6 @@ import {useCurrentConvoId} from '#/state/messages/current-convo-id'
import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useConvoQuery} from '#/state/queries/messages/conversation' import {useConvoQuery} from '#/state/queries/messages/conversation'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {MessagesList} from '#/screens/Messages/components/MessagesList' import {MessagesList} from '#/screens/Messages/components/MessagesList'
import {atoms as a, useTheme, web} from '#/alf' import {atoms as a, useTheme, web} from '#/alf'
import {AgeRestrictedScreen} from '#/components/ageAssurance/AgeRestrictedScreen' import {AgeRestrictedScreen} from '#/components/ageAssurance/AgeRestrictedScreen'
@@ -70,25 +69,22 @@ export function MessagesConversationScreen(props: Props) {
} }
export function MessagesConversationScreenInner({route}: Props) { export function MessagesConversationScreenInner({route}: Props) {
const setMinimalShellMode = useSetMinimalShellMode()
const convoId = route.params.conversation const convoId = route.params.conversation
const {setCurrentConvoId} = useCurrentConvoId() const {setCurrentConvoId} = useCurrentConvoId()
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setCurrentConvoId(convoId) setCurrentConvoId(convoId)
setMinimalShellMode(true)
return () => { return () => {
setCurrentConvoId(undefined) setCurrentConvoId(undefined)
setMinimalShellMode(false)
} }
}, [convoId, setCurrentConvoId, setMinimalShellMode]), }, [convoId, setCurrentConvoId]),
) )
return ( return (
<Layout.Screen <Layout.Screen
minimalShell
testID="convoScreen" testID="convoScreen"
noInsetTop={IS_LIQUID_GLASS} noInsetTop={IS_LIQUID_GLASS}
style={web([{minHeight: 0}, a.flex_1])}> style={web([{minHeight: 0}, a.flex_1])}>
-9
View File
@@ -4,7 +4,6 @@ import {LABELS} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {getLabelingServiceTitle, isAppLabeler} from '#/lib/moderation' import {getLabelingServiceTitle, isAppLabeler} from '#/lib/moderation'
import { import {
@@ -21,7 +20,6 @@ import {
usePreferencesSetAdultContentMutation, usePreferencesSetAdultContentMutation,
} from '#/state/queries/preferences' } from '#/state/queries/preferences'
import {isNonConfigurableModerationAuthority} from '#/state/session/additional-moderation-authorities' import {isNonConfigurableModerationAuthority} from '#/state/session/additional-moderation-authorities'
import {useSetMinimalShellMode} from '#/state/shell'
import {atoms as a, useBreakpoints, useTheme, type ViewStyleProp} from '#/alf' import {atoms as a, useBreakpoints, useTheme, type ViewStyleProp} from '#/alf'
import * as Admonition from '#/components/Admonition' import * as Admonition from '#/components/Admonition'
import {AgeAssuranceAdmonition} from '#/components/ageAssurance/AgeAssuranceAdmonition' import {AgeAssuranceAdmonition} from '#/components/ageAssurance/AgeAssuranceAdmonition'
@@ -161,7 +159,6 @@ export function ModerationScreenInner({
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const setMinimalShellMode = useSetMinimalShellMode()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const {mutedWordsDialogControl} = useGlobalDialogsControlContext() const {mutedWordsDialogControl} = useGlobalDialogsControlContext()
const { const {
@@ -197,12 +194,6 @@ export function ModerationScreenInner({
} }
} }
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const {mutateAsync: setAdultContentPref, variables: optimisticAdultContent} = const {mutateAsync: setAdultContentPref, variables: optimisticAdultContent} =
usePreferencesSetAdultContentMutation() usePreferencesSetAdultContentMutation()
let adultContentEnabled = !!( let adultContentEnabled = !!(
-10
View File
@@ -1,6 +1,4 @@
import {useCallback} from 'react'
import {Plural, Trans} from '@lingui/react/macro' import {Plural, Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
@@ -8,13 +6,11 @@ import {
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {usePostQuery} from '#/state/queries/post' import {usePostQuery} from '#/state/queries/post'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy' import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostLikedBy'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostLikedBy'>
export const PostLikedByScreen = ({route}: Props) => { export const PostLikedByScreen = ({route}: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const {data: post} = usePostQuery(uri) const {data: post} = usePostQuery(uri)
@@ -24,12 +20,6 @@ export const PostLikedByScreen = ({route}: Props) => {
likeCount = post.likeCount likeCount = post.likeCount
} }
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<Layout.Header.Outer> <Layout.Header.Outer>
-10
View File
@@ -1,6 +1,4 @@
import {useCallback} from 'react'
import {Plural, Trans} from '@lingui/react/macro' import {Plural, Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
@@ -8,13 +6,11 @@ import {
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {usePostQuery} from '#/state/queries/post' import {usePostQuery} from '#/state/queries/post'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostQuotes as PostQuotesComponent} from '#/view/com/post-thread/PostQuotes' import {PostQuotes as PostQuotesComponent} from '#/view/com/post-thread/PostQuotes'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostQuotes'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostQuotes'>
export const PostQuotesScreen = ({route}: Props) => { export const PostQuotesScreen = ({route}: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const {data: post} = usePostQuery(uri) const {data: post} = usePostQuery(uri)
@@ -24,12 +20,6 @@ export const PostQuotesScreen = ({route}: Props) => {
quoteCount = post.quoteCount quoteCount = post.quoteCount
} }
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<Layout.Header.Outer> <Layout.Header.Outer>
-10
View File
@@ -1,6 +1,4 @@
import {useCallback} from 'react'
import {Plural, Trans} from '@lingui/react/macro' import {Plural, Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
@@ -8,7 +6,6 @@ import {
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {usePostQuery} from '#/state/queries/post' import {usePostQuery} from '#/state/queries/post'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostRepostedBy as PostRepostedByComponent} from '#/view/com/post-thread/PostRepostedBy' import {PostRepostedBy as PostRepostedByComponent} from '#/view/com/post-thread/PostRepostedBy'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
@@ -16,7 +13,6 @@ type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostRepostedBy'>
export const PostRepostedByScreen = ({route}: Props) => { export const PostRepostedByScreen = ({route}: Props) => {
const {name, rkey} = route.params const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const setMinimalShellMode = useSetMinimalShellMode()
const {data: post} = usePostQuery(uri) const {data: post} = usePostQuery(uri)
let quoteCount let quoteCount
@@ -24,12 +20,6 @@ export const PostRepostedByScreen = ({route}: Props) => {
quoteCount = post.repostCount quoteCount = post.repostCount
} }
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<Layout.Header.Outer> <Layout.Header.Outer>
+5 -14
View File
@@ -1,8 +1,7 @@
import {useCallback, useMemo, useState} from 'react' import {useMemo, useState} from 'react'
import {type AppBskyActorDefs} from '@atproto/api' import {type AppBskyActorDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useFocusEffect} from '@react-navigation/native'
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import { import {
@@ -13,7 +12,6 @@ import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
import {useProfileKnownFollowersQuery} from '#/state/queries/known-followers' import {useProfileKnownFollowersQuery} from '#/state/queries/known-followers'
import {useResolveDidQuery} from '#/state/queries/resolve-uri' import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard' import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
import {ViewHeader} from '#/view/com/util/ViewHeader' import {ViewHeader} from '#/view/com/util/ViewHeader'
@@ -46,7 +44,6 @@ type Props = NativeStackScreenProps<
> >
export const ProfileKnownFollowersScreen = ({route}: Props) => { export const ProfileKnownFollowersScreen = ({route}: Props) => {
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const initialNumToRender = useInitialNumToRender() const initialNumToRender = useInitialNumToRender()
const {name} = route.params const {name} = route.params
@@ -67,7 +64,7 @@ export const ProfileKnownFollowersScreen = ({route}: Props) => {
refetch, refetch,
} = useProfileKnownFollowersQuery(resolvedDid) } = useProfileKnownFollowersQuery(resolvedDid)
const onRefresh = useCallback(async () => { const onRefresh = async () => {
setIsPTRing(true) setIsPTRing(true)
try { try {
await refetch() await refetch()
@@ -75,16 +72,16 @@ export const ProfileKnownFollowersScreen = ({route}: Props) => {
logger.error('Failed to refresh followers', {message: err}) logger.error('Failed to refresh followers', {message: err})
} }
setIsPTRing(false) setIsPTRing(false)
}, [refetch, setIsPTRing]) }
const onEndReached = useCallback(async () => { const onEndReached = async () => {
if (isFetchingNextPage || !hasNextPage || !!error) return if (isFetchingNextPage || !hasNextPage || !!error) return
try { try {
await fetchNextPage() await fetchNextPage()
} catch (err) { } catch (err) {
logger.error('Failed to load more followers', {message: err}) logger.error('Failed to load more followers', {message: err})
} }
}, [isFetchingNextPage, hasNextPage, error, fetchNextPage]) }
const followers = useMemo(() => { const followers = useMemo(() => {
if (data?.pages) { if (data?.pages) {
@@ -95,12 +92,6 @@ export const ProfileKnownFollowersScreen = ({route}: Props) => {
const isError = Boolean(resolveError || error) const isError = Boolean(resolveError || error)
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
if (followers.length < 1) { if (followers.length < 1) {
return ( return (
<Layout.Screen> <Layout.Screen>
-10
View File
@@ -1,6 +1,4 @@
import {useCallback} from 'react'
import {Plural} from '@lingui/react/macro' import {Plural} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
@@ -9,26 +7,18 @@ import {
import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {useProfileQuery} from '#/state/queries/profile' import {useProfileQuery} from '#/state/queries/profile'
import {useResolveDidQuery} from '#/state/queries/resolve-uri' import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileFollowers as ProfileFollowersComponent} from '#/view/com/profile/ProfileFollowers' import {ProfileFollowers as ProfileFollowersComponent} from '#/view/com/profile/ProfileFollowers'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollowers'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollowers'>
export const ProfileFollowersScreen = ({route}: Props) => { export const ProfileFollowersScreen = ({route}: Props) => {
const {name} = route.params const {name} = route.params
const setMinimalShellMode = useSetMinimalShellMode()
const {data: resolvedDid} = useResolveDidQuery(name) const {data: resolvedDid} = useResolveDidQuery(name)
const {data: profile} = useProfileQuery({ const {data: profile} = useProfileQuery({
did: resolvedDid, did: resolvedDid,
}) })
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen testID="profileFollowersScreen"> <Layout.Screen testID="profileFollowersScreen">
<Layout.Header.Outer> <Layout.Header.Outer>
-10
View File
@@ -1,6 +1,4 @@
import {useCallback} from 'react'
import {Plural} from '@lingui/react/macro' import {Plural} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
@@ -9,26 +7,18 @@ import {
import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {useProfileQuery} from '#/state/queries/profile' import {useProfileQuery} from '#/state/queries/profile'
import {useResolveDidQuery} from '#/state/queries/resolve-uri' import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileFollows as ProfileFollowsComponent} from '#/view/com/profile/ProfileFollows' import {ProfileFollows as ProfileFollowsComponent} from '#/view/com/profile/ProfileFollows'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollows'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFollows'>
export const ProfileFollowsScreen = ({route}: Props) => { export const ProfileFollowsScreen = ({route}: Props) => {
const {name} = route.params const {name} = route.params
const setMinimalShellMode = useSetMinimalShellMode()
const {data: resolvedDid} = useResolveDidQuery(name) const {data: resolvedDid} = useResolveDidQuery(name)
const {data: profile} = useProfileQuery({ const {data: profile} = useProfileQuery({
did: resolvedDid, did: resolvedDid,
}) })
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen testID="profileFollowsScreen"> <Layout.Screen testID="profileFollowsScreen">
<Layout.Header.Outer> <Layout.Header.Outer>
@@ -1,14 +1,11 @@
import {useCallback} from 'react'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {useSetMinimalShellMode} from '#/state/shell'
import {ViewHeader} from '#/view/com/util/ViewHeader' import {ViewHeader} from '#/view/com/util/ViewHeader'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
import {LikedByList} from '#/components/LikedByList' import {LikedByList} from '#/components/LikedByList'
@@ -16,17 +13,10 @@ import {LikedByList} from '#/components/LikedByList'
export function ProfileLabelerLikedByScreen({ export function ProfileLabelerLikedByScreen({
route, route,
}: NativeStackScreenProps<CommonNavigatorParams, 'ProfileLabelerLikedBy'>) { }: NativeStackScreenProps<CommonNavigatorParams, 'ProfileLabelerLikedBy'>) {
const setMinimalShellMode = useSetMinimalShellMode()
const {name: handleOrDid} = route.params const {name: handleOrDid} = route.params
const uri = makeRecordUri(handleOrDid, 'app.bsky.labeler.service', 'self') const uri = makeRecordUri(handleOrDid, 'app.bsky.labeler.service', 'self')
const {_} = useLingui() const {_} = useLingui()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<ViewHeader title={_(msg`Liked By`)} /> <ViewHeader title={_(msg`Liked By`)} />
+1 -9
View File
@@ -10,7 +10,7 @@ import {
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect, useIsFocused} from '@react-navigation/native' import {useIsFocused} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
@@ -31,7 +31,6 @@ import {
import {useResolveUriQuery} from '#/state/queries/resolve-uri' import {useResolveUriQuery} from '#/state/queries/resolve-uri'
import {truncateAndInvalidate} from '#/state/queries/util' import {truncateAndInvalidate} from '#/state/queries/util'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {PagerWithHeader} from '#/view/com/pager/PagerWithHeader' import {PagerWithHeader} from '#/view/com/pager/PagerWithHeader'
import {FAB} from '#/view/com/util/fab/FAB' import {FAB} from '#/view/com/util/fab/FAB'
import {type ListRef} from '#/view/com/util/List' import {type ListRef} from '#/view/com/util/List'
@@ -155,7 +154,6 @@ function ProfileListScreenLoaded({
const {_} = useLingui() const {_} = useLingui()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const {openComposer} = useOpenComposer() const {openComposer} = useOpenComposer()
const setMinimalShellMode = useSetMinimalShellMode()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const {rkey} = route.params const {rkey} = route.params
const feedSectionRef = useRef<SectionRef>(null) const feedSectionRef = useRef<SectionRef>(null)
@@ -176,12 +174,6 @@ function ProfileListScreenLoaded({
useSetTitle(isHidden ? _(msg`List Hidden`) : list.name) useSetTitle(isHidden ? _(msg`List Hidden`) : list.name)
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onChangeMembers = () => { const onChangeMembers = () => {
if (isCurateList) { if (isCurateList) {
truncateAndInvalidate(queryClient, FEED_RQKEY(`list|${list.uri}`)) truncateAndInvalidate(queryClient, FEED_RQKEY(`list|${list.uri}`))
+2 -17
View File
@@ -1,4 +1,4 @@
import {useCallback, useState} from 'react' import {useState} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import type Animated from 'react-native-reanimated' import type Animated from 'react-native-reanimated'
import {useAnimatedRef, useScrollViewOffset} from 'react-native-reanimated' import {useAnimatedRef, useScrollViewOffset} from 'react-native-reanimated'
@@ -7,7 +7,7 @@ import {TID} from '@atproto/common-web'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {RECOMMENDED_SAVED_FEEDS, TIMELINE_SAVED_FEED} from '#/lib/constants' import {RECOMMENDED_SAVED_FEEDS, TIMELINE_SAVED_FEED} from '#/lib/constants'
@@ -23,7 +23,6 @@ import {
usePreferencesQuery, usePreferencesQuery,
} from '#/state/queries/preferences' } from '#/state/queries/preferences'
import {type UsePreferencesQueryResponse} from '#/state/queries/preferences/types' import {type UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
import {useSetMinimalShellMode} from '#/state/shell'
import {FeedSourceCard} from '#/view/com/feeds/FeedSourceCard' import {FeedSourceCard} from '#/view/com/feeds/FeedSourceCard'
import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed' import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed'
import {NoSavedFeedsOfAnyType} from '#/screens/Feeds/NoSavedFeedsOfAnyType' import {NoSavedFeedsOfAnyType} from '#/screens/Feeds/NoSavedFeedsOfAnyType'
@@ -66,7 +65,6 @@ function SavedFeedsInner({
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const setMinimalShellMode = useSetMinimalShellMode()
const {mutateAsync: overwriteSavedFeeds, isPending: isOverwritePending} = const {mutateAsync: overwriteSavedFeeds, isPending: isOverwritePending} =
useOverwriteSavedFeedsMutation() useOverwriteSavedFeedsMutation()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
@@ -88,12 +86,6 @@ function SavedFeedsInner({
currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeedsOfAnyType currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeedsOfAnyType
const [isDragging, setIsDragging] = useState(false) const [isDragging, setIsDragging] = useState(false)
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onSaveChanges = async () => { const onSaveChanges = async () => {
try { try {
await overwriteSavedFeeds(currentFeeds) await overwriteSavedFeeds(currentFeeds)
@@ -259,7 +251,6 @@ function SavedFeedsA11y({
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {gtMobile} = useBreakpoints() const {gtMobile} = useBreakpoints()
const setMinimalShellMode = useSetMinimalShellMode()
const {mutateAsync: overwriteSavedFeeds, isPending: isOverwritePending} = const {mutateAsync: overwriteSavedFeeds, isPending: isOverwritePending} =
useOverwriteSavedFeedsMutation() useOverwriteSavedFeedsMutation()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
@@ -274,12 +265,6 @@ function SavedFeedsA11y({
const noFollowingFeed = const noFollowingFeed =
currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeedsOfAnyType currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeedsOfAnyType
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onSaveChanges = async () => { const onSaveChanges = async () => {
try { try {
await overwriteSavedFeeds(currentFeeds) await overwriteSavedFeeds(currentFeeds)
+4 -12
View File
@@ -27,7 +27,6 @@ import {
useProfilesQuery, useProfilesQuery,
} from '#/state/queries/profile' } from '#/state/queries/profile'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import { import {
makeSearchQuery, makeSearchQuery,
type Params, type Params,
@@ -87,7 +86,6 @@ export function SearchScreenShell({
const route = useRoute() const route = useRoute()
const textInput = useRef<TextInput>(null) const textInput = useRef<TextInput>(null)
const {t: l} = useLingui() const {t: l} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const queryClient = useQueryClient() const queryClient = useQueryClient()
@@ -288,9 +286,8 @@ export function SearchScreenShell({
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setMinimalShellMode(false)
return listenSoftReset(onSoftReset) return listenSoftReset(onSoftReset)
}, [onSoftReset, setMinimalShellMode]), }, [onSoftReset]),
) )
const onSearchInputFocus = useCallback(() => { const onSearchInputFocus = useCallback(() => {
@@ -481,17 +478,12 @@ let SearchScreenInner = ({
focusSearchInput: (tab?: TabParam) => void focusSearchInput: (tab?: TabParam) => void
}): React.ReactNode => { }): React.ReactNode => {
const t = useTheme() const t = useTheme()
const setMinimalShellMode = useSetMinimalShellMode()
const {hasSession} = useSession() const {hasSession} = useSession()
const {gtTablet} = useBreakpoints() const {gtTablet} = useBreakpoints()
const onPageSelected = useCallback( const onPageSelected = (index: number) => {
(index: number) => { setActiveTab(index)
setMinimalShellMode(false) }
setActiveTab(index)
},
[setActiveTab, setMinimalShellMode],
)
return queryWithParams ? ( return queryWithParams ? (
<SearchResults <SearchResults
+3 -14
View File
@@ -1,4 +1,4 @@
import {useCallback, useEffect} from 'react' import {useEffect} from 'react'
import {Keyboard, View} from 'react-native' import {Keyboard, View} from 'react-native'
import {KeyboardAwareScrollView} from 'react-native-keyboard-controller' import {KeyboardAwareScrollView} from 'react-native-keyboard-controller'
import {useSafeAreaInsets} from 'react-native-safe-area-context' import {useSafeAreaInsets} from 'react-native-safe-area-context'
@@ -13,7 +13,7 @@ import {
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Plural, Trans} from '@lingui/react/macro' import {Plural, Trans} from '@lingui/react/macro'
import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {STARTER_PACK_MAX_SIZE} from '#/lib/constants' import {STARTER_PACK_MAX_SIZE} from '#/lib/constants'
@@ -39,7 +39,6 @@ import {
useStarterPackQuery, useStarterPackQuery,
} from '#/state/queries/starter-packs' } from '#/state/queries/starter-packs'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
import { import {
useWizardState, useWizardState,
@@ -132,6 +131,7 @@ export function Wizard({
return ( return (
<Layout.Screen <Layout.Screen
minimalShell
testID="starterPackWizardScreen" testID="starterPackWizardScreen"
style={web([{minHeight: 0}, a.flex_1])}> style={web([{minHeight: 0}, a.flex_1])}>
<Provider <Provider
@@ -169,7 +169,6 @@ function WizardInner({
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const ax = useAnalytics() const ax = useAnalytics()
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const [state, dispatch] = useWizardState() const [state, dispatch] = useWizardState()
const {currentAccount} = useSession() const {currentAccount} = useSession()
@@ -185,16 +184,6 @@ function WizardInner({
}) })
}, [navigation]) }, [navigation])
useFocusEffect(
useCallback(() => {
setMinimalShellMode(true)
return () => {
setMinimalShellMode(false)
}
}, [setMinimalShellMode]),
)
const getDefaultName = () => { const getDefaultName = () => {
const displayName = createSanitizedDisplayName(currentProfile!, true) const displayName = createSanitizedDisplayName(currentProfile!, true)
return _(msg`${displayName}'s Starter Pack`).slice(0, 50) return _(msg`${displayName}'s Starter Pack`).slice(0, 50)
+3 -16
View File
@@ -3,7 +3,6 @@ import {type ListRenderItemInfo, View} from 'react-native'
import {type AppBskyFeedDefs} from '@atproto/api' import {type AppBskyFeedDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useFocusEffect} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {HITSLOP_10} from '#/lib/constants' import {HITSLOP_10} from '#/lib/constants'
@@ -14,7 +13,6 @@ import {shareUrl} from '#/lib/sharing'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {enforceLen} from '#/lib/strings/helpers' import {enforceLen} from '#/lib/strings/helpers'
import {useSearchPostsQuery} from '#/state/queries/search-posts' import {useSearchPostsQuery} from '#/state/queries/search-posts'
import {useSetMinimalShellMode} from '#/state/shell'
import {Pager} from '#/view/com/pager/Pager' import {Pager} from '#/view/com/pager/Pager'
import {TabBar} from '#/view/com/pager/TabBar' import {TabBar} from '#/view/com/pager/TabBar'
import {Post} from '#/view/com/post/Post' import {Post} from '#/view/com/post/Post'
@@ -50,21 +48,10 @@ export default function TopicScreen({
}, [topic]) }, [topic])
const [activeTab, setActiveTab] = useState(0) const [activeTab, setActiveTab] = useState(0)
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect( const onPageSelected = (index: number) => {
useCallback(() => { setActiveTab(index)
setMinimalShellMode(false) }
}, [setMinimalShellMode]),
)
const onPageSelected = useCallback(
(index: number) => {
setMinimalShellMode(false)
setActiveTab(index)
},
[setMinimalShellMode],
)
const sections = useMemo(() => { const sections = useMemo(() => {
return [ return [
+2 -6
View File
@@ -75,7 +75,6 @@ import {
} from '#/state/queries/post-feed' } from '#/state/queries/post-feed'
import {useProfileFollowMutationQueue} from '#/state/queries/profile' import {useProfileFollowMutationQueue} from '#/state/queries/profile'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {useSetLightStatusBar} from '#/state/shell/light-status-bar' import {useSetLightStatusBar} from '#/state/shell/light-status-bar'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
@@ -131,16 +130,13 @@ export function VideoFeed({}: NativeStackScreenProps<
const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>() const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>()
const t = useTheme() const t = useTheme()
const setMinShellMode = useSetMinimalShellMode()
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setMinShellMode(true)
setSystemUITheme('lightbox', t) setSystemUITheme('lightbox', t)
return () => { return () => {
setMinShellMode(false)
setSystemUITheme('theme', t) setSystemUITheme('theme', t)
} }
}, [setMinShellMode, t]), }, [t]),
) )
const isFocused = useIsFocused() const isFocused = useIsFocused()
@@ -148,7 +144,7 @@ export function VideoFeed({}: NativeStackScreenProps<
return ( return (
<ThemeProvider theme="dark"> <ThemeProvider theme="dark">
<Layout.Screen noInsetTop style={{backgroundColor: 'black'}}> <Layout.Screen minimalShell noInsetTop style={{backgroundColor: 'black'}}>
<KeepAwake /> <KeepAwake />
<View <View
style={[ style={[
+5 -1
View File
@@ -11,7 +11,11 @@ export {
useIsDrawerSwipeDisabled, useIsDrawerSwipeDisabled,
useSetDrawerSwipeDisabled, useSetDrawerSwipeDisabled,
} from './drawer-swipe-disabled' } from './drawer-swipe-disabled'
export {useMinimalShellMode, useSetMinimalShellMode} from './minimal-mode' export {
useEnableMinimalShellMode,
useEnableMinimalShellModeForScreen,
useMinimalShellMode,
} from './minimal-mode'
export {useOnboardingDispatch, useOnboardingState} from './onboarding' export {useOnboardingDispatch, useOnboardingState} from './onboarding'
export {useTickEveryMinute} from './tick-every-minute' export {useTickEveryMinute} from './tick-every-minute'
+80 -30
View File
@@ -1,46 +1,37 @@
import {createContext, useCallback, useContext, useMemo} from 'react' import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
} from 'react'
import { import {
type SharedValue, type SharedValue,
useSharedValue, useSharedValue,
withSpring, withSpring,
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {useFocusEffect} from '@react-navigation/native'
type StateContext = { type StateContext = {
headerMode: SharedValue<number> headerMode: SharedValue<number>
footerMode: SharedValue<number> footerMode: SharedValue<number>
} }
type SetContext = (v: boolean) => void type SetContext = {
add: () => void
subtract: () => void
}
const stateContext = createContext<StateContext>({ const stateContext = createContext<StateContext | null>(null)
headerMode: {
value: 0,
addListener() {},
removeListener() {},
modify() {},
get() {
return 0
},
set() {},
},
footerMode: {
value: 0,
addListener() {},
removeListener() {},
modify() {},
get() {
return 0
},
set() {},
},
})
stateContext.displayName = 'MinimalModeStateContext' stateContext.displayName = 'MinimalModeStateContext'
const setContext = createContext<SetContext>((_: boolean) => {}) const setContext = createContext<SetContext | null>(null)
setContext.displayName = 'MinimalModeSetContext' setContext.displayName = 'MinimalModeSetContext'
export function Provider({children}: React.PropsWithChildren<{}>) { export function Provider({children}: React.PropsWithChildren<{}>) {
const headerMode = useSharedValue(0) const headerMode = useSharedValue(0)
const footerMode = useSharedValue(0) const footerMode = useSharedValue(0)
const setMode = useCallback(
const setModeWorklet = useCallback(
(v: boolean) => { (v: boolean) => {
'worklet' 'worklet'
headerMode.set(() => headerMode.set(() =>
@@ -56,6 +47,31 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
}, },
[headerMode, footerMode], [headerMode, footerMode],
) )
// defaults to "visible", if the count is >0 it gets hidden
const countRef = useRef(0)
const add = useCallback(() => {
// 0 -> 1 = hide
if (countRef.current === 0) setModeWorklet(true)
countRef.current += 1
}, [setModeWorklet])
const subtract = useCallback(() => {
// 1 -> 0 = show
if (countRef.current === 1) setModeWorklet(false)
// count must never go below 0
if (countRef.current > 0) countRef.current -= 1
}, [setModeWorklet])
const setters = useMemo(
() => ({
add,
subtract,
}),
[add, subtract],
)
const value = useMemo( const value = useMemo(
() => ({ () => ({
headerMode, headerMode,
@@ -65,15 +81,49 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
) )
return ( return (
<stateContext.Provider value={value}> <stateContext.Provider value={value}>
<setContext.Provider value={setMode}>{children}</setContext.Provider> <setContext.Provider value={setters}>{children}</setContext.Provider>
</stateContext.Provider> </stateContext.Provider>
) )
} }
export function useMinimalShellMode() { export function useMinimalShellMode() {
return useContext(stateContext) const context = useContext(stateContext)
if (!context)
throw new Error(
'useMinimalShellMode must be used within a MinimalModeProvider',
)
return context
} }
export function useSetMinimalShellMode() { export function useMinimalShellModeSetters() {
return useContext(setContext) const context = useContext(setContext)
if (!context)
throw new Error(
'useMinimalShellModeSetters must be used within a MinimalModeProvider',
)
return context
}
export function useEnableMinimalShellMode({enabled} = {enabled: true}) {
const setters = useMinimalShellModeSetters()
useEffect(() => {
if (enabled) {
setters.add()
return () => setters.subtract()
}
}, [enabled, setters])
}
export function useEnableMinimalShellModeForScreen(
{enabled} = {enabled: true},
) {
const setters = useMinimalShellModeSetters()
useFocusEffect(
useCallback(() => {
if (enabled) {
setters.add()
return () => setters.subtract()
}
}, [enabled, setters]),
)
} }
+2 -6
View File
@@ -13,7 +13,7 @@ import {
useLoggedOutView, useLoggedOutView,
useLoggedOutViewControls, useLoggedOutViewControls,
} from '#/state/shell/logged-out' } from '#/state/shell/logged-out'
import {useSetMinimalShellMode} from '#/state/shell/minimal-mode' import {useEnableMinimalShellMode} from '#/state/shell/minimal-mode'
import {ErrorBoundary} from '#/view/com/util/ErrorBoundary' import {ErrorBoundary} from '#/view/com/util/ErrorBoundary'
import {Login} from '#/screens/Login' import {Login} from '#/screens/Login'
import {Signup} from '#/screens/Signup' import {Signup} from '#/screens/Signup'
@@ -37,7 +37,7 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) {
const ax = useAnalytics() const ax = useAnalytics()
const t = useTheme() const t = useTheme()
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
const setMinimalShellMode = useSetMinimalShellMode() useEnableMinimalShellMode()
const {requestedAccountSwitchTo} = useLoggedOutView() const {requestedAccountSwitchTo} = useLoggedOutView()
const [screenState, setScreenState] = useState<ScreenState>(() => { const [screenState, setScreenState] = useState<ScreenState>(() => {
if (requestedAccountSwitchTo === 'new') { if (requestedAccountSwitchTo === 'new') {
@@ -68,10 +68,6 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) {
}) })
}, [accounts, agent, queryClient]) }, [accounts, agent, queryClient])
useEffect(() => {
setMinimalShellMode(true)
}, [setMinimalShellMode])
const onPressDismiss = useCallback(() => { const onPressDismiss = useCallback(() => {
if (onDismiss) { if (onDismiss) {
onDismiss() onDismiss()
+1 -4
View File
@@ -30,7 +30,6 @@ import {
} from '#/state/queries/post-feed' } from '#/state/queries/post-feed'
import {truncateAndInvalidate} from '#/state/queries/util' import {truncateAndInvalidate} from '#/state/queries/util'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {useHeaderOffset} from '#/components/hooks/useHeaderOffset' import {useHeaderOffset} from '#/components/hooks/useHeaderOffset'
import {useAnalytics} from '#/analytics' import {useAnalytics} from '#/analytics'
import {IS_NATIVE} from '#/env' import {IS_NATIVE} from '#/env'
@@ -70,7 +69,6 @@ export function FeedPage({
const queryClient = useQueryClient() const queryClient = useQueryClient()
const {openComposer} = useOpenComposer() const {openComposer} = useOpenComposer()
const [isScrolledDown, setIsScrolledDown] = useState(false) const [isScrolledDown, setIsScrolledDown] = useState(false)
const setMinimalShellMode = useSetMinimalShellMode()
const headerOffset = useHeaderOffset() const headerOffset = useHeaderOffset()
const feedFeedback = useFeedFeedback(feedInfo, hasSession) const feedFeedback = useFeedFeedback(feedInfo, hasSession)
const scrollElRef = useRef<ListMethods>(null) const scrollElRef = useRef<ListMethods>(null)
@@ -95,8 +93,7 @@ export function FeedPage({
animated: IS_NATIVE, animated: IS_NATIVE,
offset: -headerOffset, offset: -headerOffset,
}) })
setMinimalShellMode(false) }, [headerOffset])
}, [headerOffset, setMinimalShellMode])
const onSoftReset = useCallback(() => { const onSoftReset = useCallback(() => {
const isScreenFocused = const isScreenFocused =
-10
View File
@@ -1,9 +1,7 @@
import {useCallback} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import { import {
@@ -11,7 +9,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {TextLink} from '#/view/com/util/Link' import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ScrollView} from '#/view/com/util/Views' import {ScrollView} from '#/view/com/util/Views'
@@ -25,13 +22,6 @@ type Props = NativeStackScreenProps<
export const CommunityGuidelinesScreen = (_props: Props) => { export const CommunityGuidelinesScreen = (_props: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
-10
View File
@@ -1,9 +1,7 @@
import {useCallback} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import { import {
@@ -11,7 +9,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {TextLink} from '#/view/com/util/Link' import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ScrollView} from '#/view/com/util/Views' import {ScrollView} from '#/view/com/util/Views'
@@ -22,13 +19,6 @@ type Props = NativeStackScreenProps<CommonNavigatorParams, 'CopyrightPolicy'>
export const CopyrightPolicyScreen = (_props: Props) => { export const CopyrightPolicyScreen = (_props: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
-9
View File
@@ -4,7 +4,6 @@ import {type AppBskyFeedDefs} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import debounce from 'lodash.debounce' import debounce from 'lodash.debounce'
import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
@@ -24,7 +23,6 @@ import {
useSearchPopularFeedsMutation, useSearchPopularFeedsMutation,
} from '#/state/queries/feed' } from '#/state/queries/feed'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
import {FAB} from '#/view/com/util/fab/FAB' import {FAB} from '#/view/com/util/fab/FAB'
import {List, type ListMethods} from '#/view/com/util/List' import {List, type ListMethods} from '#/view/com/util/List'
@@ -126,7 +124,6 @@ export function FeedsScreen(_props: Props) {
hasNextPage: hasNextPopularFeedsPage, hasNextPage: hasNextPopularFeedsPage,
} = useGetPopularFeedsQuery() } = useGetPopularFeedsQuery()
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const { const {
data: searchResults, data: searchResults,
mutate: search, mutate: search,
@@ -193,12 +190,6 @@ export function FeedsScreen(_props: Props) {
fetchNextPopularFeedsPage, fetchNextPopularFeedsPage,
]) ])
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const items = useMemo(() => { const items = useMemo(() => {
let slices: FlatlistSlice[] = [] let slices: FlatlistSlice[] = []
const hasActualSavedCount = const hasActualSavedCount =
+14 -9
View File
@@ -1,5 +1,6 @@
import {useCallback, useEffect, useLayoutEffect, useMemo, useRef} from 'react' import {useCallback, useEffect, useLayoutEffect, useMemo, useRef} from 'react'
import {ActivityIndicator, StyleSheet} from 'react-native' import {ActivityIndicator, StyleSheet} from 'react-native'
import {withSpring} from 'react-native-reanimated'
import {useFocusEffect} from '@react-navigation/native' import {useFocusEffect} from '@react-navigation/native'
import {PROD_DEFAULT_FEED} from '#/lib/constants' import {PROD_DEFAULT_FEED} from '#/lib/constants'
@@ -20,7 +21,7 @@ import {type FeedDescriptor, type FeedParams} from '#/state/queries/post-feed'
import {usePreferencesQuery} from '#/state/queries/preferences' import {usePreferencesQuery} from '#/state/queries/preferences'
import {type UsePreferencesQueryResponse} from '#/state/queries/preferences/types' import {type UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell' import {useMinimalShellMode} from '#/state/shell'
import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
import {FeedPage} from '#/view/com/feeds/FeedPage' import {FeedPage} from '#/view/com/feeds/FeedPage'
@@ -138,11 +139,16 @@ function HomeScreenReady({
}, [selectedIndex]) }, [selectedIndex])
const {hasSession} = useSession() const {hasSession} = useSession()
const setMinimalShellMode = useSetMinimalShellMode() const {headerMode} = useMinimalShellMode()
const showHeader = useCallback(() => {
'worklet'
headerMode.set(() => withSpring(0, {overshootClamping: true}))
}, [headerMode])
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setMinimalShellMode(false) return () => showHeader()
}, [setMinimalShellMode]), }, [showHeader]),
) )
useFocusEffect( useFocusEffect(
@@ -160,7 +166,7 @@ function HomeScreenReady({
const onPageSelected = useCallback( const onPageSelected = useCallback(
(index: number) => { (index: number) => {
setMinimalShellMode(false) showHeader()
const maybeFeed = allFeeds[index] const maybeFeed = allFeeds[index]
// Mutate the ref before setting state to avoid the imperative syncing effect // Mutate the ref before setting state to avoid the imperative syncing effect
@@ -176,7 +182,7 @@ function HomeScreenReady({
}) })
} }
}, },
[ax, setSelectedFeed, setMinimalShellMode, allFeeds], [ax, setSelectedFeed, showHeader, allFeeds],
) )
const onPressSelected = useCallback(() => { const onPressSelected = useCallback(() => {
@@ -187,10 +193,10 @@ function HomeScreenReady({
(state: 'idle' | 'dragging' | 'settling') => { (state: 'idle' | 'dragging' | 'settling') => {
'worklet' 'worklet'
if (state === 'dragging') { if (state === 'dragging') {
setMinimalShellMode(false) showHeader()
} }
}, },
[setMinimalShellMode], [showHeader],
) )
const [demoMode] = useDemoMode() const [demoMode] = useDemoMode()
@@ -247,7 +253,6 @@ function HomeScreenReady({
ref={pagerRef} ref={pagerRef}
testID="homeScreen" testID="homeScreen"
onPageSelected={onPageSelected} onPageSelected={onPageSelected}
onPageScrollStateChanged={onPageScrollStateChanged}
renderTabBar={renderTabBar} renderTabBar={renderTabBar}
initialPage={selectedIndex}> initialPage={selectedIndex}>
<FeedPage <FeedPage
+1 -9
View File
@@ -3,7 +3,7 @@ import {AtUri} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification' import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
import { import {
@@ -11,7 +11,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
type NavigationProp, type NavigationProp,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {useSetMinimalShellMode} from '#/state/shell'
import {MyLists} from '#/view/com/lists/MyLists' import {MyLists} from '#/view/com/lists/MyLists'
import {atoms as a} from '#/alf' import {atoms as a} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Button, ButtonIcon, ButtonText} from '#/components/Button'
@@ -23,17 +22,10 @@ import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Lists'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'Lists'>
export function ListsScreen({}: Props) { export function ListsScreen({}: Props) {
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const requireEmailVerification = useRequireEmailVerification() const requireEmailVerification = useRequireEmailVerification()
const createListDialogControl = useDialogControl() const createListDialogControl = useDialogControl()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onPressNewList = useCallback(() => { const onPressNewList = useCallback(() => {
createListDialogControl.open() createListDialogControl.open()
}, [createListDialogControl]) }, [createListDialogControl])
@@ -2,7 +2,6 @@ import {useCallback, useMemo, useState} from 'react'
import {type StyleProp, View, type ViewStyle} from 'react-native' import {type StyleProp, View, type ViewStyle} from 'react-native'
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api' import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {type CommonNavigatorParams} from '#/lib/routes/types' import {type CommonNavigatorParams} from '#/lib/routes/types'
@@ -10,7 +9,6 @@ import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useMyBlockedAccountsQuery} from '#/state/queries/my-blocked-accounts' import {useMyBlockedAccountsQuery} from '#/state/queries/my-blocked-accounts'
import {useSetMinimalShellMode} from '#/state/shell'
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
@@ -25,7 +23,6 @@ type Props = NativeStackScreenProps<
> >
export function ModerationBlockedAccounts({}: Props) { export function ModerationBlockedAccounts({}: Props) {
const t = useTheme() const t = useTheme()
const setMinimalShellMode = useSetMinimalShellMode()
const moderationOpts = useModerationOpts() const moderationOpts = useModerationOpts()
const [isPTRing, setIsPTRing] = useState(false) const [isPTRing, setIsPTRing] = useState(false)
@@ -47,12 +44,6 @@ export function ModerationBlockedAccounts({}: Props) {
return [] return []
}, [data]) }, [data])
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onRefresh = useCallback(async () => { const onRefresh = useCallback(async () => {
setIsPTRing(true) setIsPTRing(true)
try { try {
+1 -9
View File
@@ -3,7 +3,7 @@ import {AtUri} from '@atproto/api'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification' import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
import { import {
@@ -11,7 +11,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
type NavigationProp, type NavigationProp,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {useSetMinimalShellMode} from '#/state/shell'
import {MyLists} from '#/view/com/lists/MyLists' import {MyLists} from '#/view/com/lists/MyLists'
import {atoms as a} from '#/alf' import {atoms as a} from '#/alf'
import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Button, ButtonIcon, ButtonText} from '#/components/Button'
@@ -23,17 +22,10 @@ import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'>
export function ModerationModlistsScreen({}: Props) { export function ModerationModlistsScreen({}: Props) {
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const requireEmailVerification = useRequireEmailVerification() const requireEmailVerification = useRequireEmailVerification()
const createListDialogControl = useDialogControl() const createListDialogControl = useDialogControl()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onPressNewList = useCallback(() => { const onPressNewList = useCallback(() => {
createListDialogControl.open() createListDialogControl.open()
}, [createListDialogControl]) }, [createListDialogControl])
@@ -2,7 +2,6 @@ import {useCallback, useMemo, useState} from 'react'
import {type StyleProp, View, type ViewStyle} from 'react-native' import {type StyleProp, View, type ViewStyle} from 'react-native'
import {type AppBskyActorDefs as ActorDefs} from '@atproto/api' import {type AppBskyActorDefs as ActorDefs} from '@atproto/api'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type NativeStackScreenProps} from '@react-navigation/native-stack'
import {type CommonNavigatorParams} from '#/lib/routes/types' import {type CommonNavigatorParams} from '#/lib/routes/types'
@@ -10,7 +9,6 @@ import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
import {useModerationOpts} from '#/state/preferences/moderation-opts' import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useMyMutedAccountsQuery} from '#/state/queries/my-muted-accounts' import {useMyMutedAccountsQuery} from '#/state/queries/my-muted-accounts'
import {useSetMinimalShellMode} from '#/state/shell'
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
@@ -26,7 +24,6 @@ type Props = NativeStackScreenProps<
export function ModerationMutedAccounts({}: Props) { export function ModerationMutedAccounts({}: Props) {
const t = useTheme() const t = useTheme()
const moderationOpts = useModerationOpts() const moderationOpts = useModerationOpts()
const setMinimalShellMode = useSetMinimalShellMode()
const [isPTRing, setIsPTRing] = useState(false) const [isPTRing, setIsPTRing] = useState(false)
const { const {
@@ -47,12 +44,6 @@ export function ModerationMutedAccounts({}: Props) {
return [] return []
}, [data]) }, [data])
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const onRefresh = useCallback(async () => { const onRefresh = useCallback(async () => {
setIsPTRing(true) setIsPTRing(true)
try { try {
+1 -13
View File
@@ -3,16 +3,11 @@ import {StyleSheet, View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import { import {StackActions, useNavigation} from '@react-navigation/native'
StackActions,
useFocusEffect,
useNavigation,
} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import {type NavigationProp} from '#/lib/routes/types' import {type NavigationProp} from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {Button} from '#/view/com/util/forms/Button' import {Button} from '#/view/com/util/forms/Button'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ViewHeader} from '#/view/com/util/ViewHeader' import {ViewHeader} from '#/view/com/util/ViewHeader'
@@ -22,13 +17,6 @@ export const NotFoundScreen = () => {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
const canGoBack = navigation.canGoBack() const canGoBack = navigation.canGoBack()
const onPressHome = useCallback(() => { const onPressHome = useCallback(() => {
+2 -6
View File
@@ -23,7 +23,6 @@ import {
useUnreadNotificationsApi, useUnreadNotificationsApi,
} from '#/state/queries/notifications/unread' } from '#/state/queries/notifications/unread'
import {truncateAndInvalidate} from '#/state/queries/util' import {truncateAndInvalidate} from '#/state/queries/util'
import {useSetMinimalShellMode} from '#/state/shell'
import {NotificationFeed} from '#/view/com/notifications/NotificationFeed' import {NotificationFeed} from '#/view/com/notifications/NotificationFeed'
import {Pager} from '#/view/com/pager/Pager' import {Pager} from '#/view/com/pager/Pager'
import {TabBar} from '#/view/com/pager/TabBar' import {TabBar} from '#/view/com/pager/TabBar'
@@ -187,7 +186,6 @@ function NotificationsTab({
setIsLoadingLatest: (v: boolean) => void setIsLoadingLatest: (v: boolean) => void
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
const [isScrolledDown, setIsScrolledDown] = useState(false) const [isScrolledDown, setIsScrolledDown] = useState(false)
const scrollElRef = useRef<ListMethods>(null) const scrollElRef = useRef<ListMethods>(null)
const queryClient = useQueryClient() const queryClient = useQueryClient()
@@ -198,8 +196,7 @@ function NotificationsTab({
// = // =
const scrollToTop = useCallback(() => { const scrollToTop = useCallback(() => {
scrollElRef.current?.scrollToOffset({animated: IS_NATIVE, offset: 0}) scrollElRef.current?.scrollToOffset({animated: IS_NATIVE, offset: 0})
setMinimalShellMode(false) }, [scrollElRef])
}, [scrollElRef, setMinimalShellMode])
const onPressLoadLatest = useCallback(() => { const onPressLoadLatest = useCallback(() => {
scrollToTop() scrollToTop()
@@ -242,11 +239,10 @@ function NotificationsTab({
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
if (isFocusedAndActive) { if (isFocusedAndActive) {
setMinimalShellMode(false)
logger.debug('NotificationsScreen: Focus') logger.debug('NotificationsScreen: Focus')
onFocusCheckLatest() onFocusCheckLatest()
} }
}, [setMinimalShellMode, onFocusCheckLatest, isFocusedAndActive]), }, [onFocusCheckLatest, isFocusedAndActive]),
) )
useEffect(() => { useEffect(() => {
-12
View File
@@ -1,28 +1,16 @@
import {useCallback} from 'react'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostThread} from '#/screens/PostThread' import {PostThread} from '#/screens/PostThread'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'>
export function PostThreadScreen({route}: Props) { export function PostThreadScreen({route}: Props) {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen testID="postThreadScreen"> <Layout.Screen testID="postThreadScreen">
<PostThread uri={uri} /> <PostThread uri={uri} />
-10
View File
@@ -1,9 +1,7 @@
import {useCallback} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import { import {
@@ -11,7 +9,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {TextLink} from '#/view/com/util/Link' import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ScrollView} from '#/view/com/util/Views' import {ScrollView} from '#/view/com/util/Views'
@@ -22,13 +19,6 @@ type Props = NativeStackScreenProps<CommonNavigatorParams, 'PrivacyPolicy'>
export const PrivacyPolicyScreen = (_props: Props) => { export const PrivacyPolicyScreen = (_props: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
const setMinimalShellMode = useSetMinimalShellMode()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
+1 -4
View File
@@ -34,7 +34,6 @@ import {resetProfilePostsQueries} from '#/state/queries/post-feed'
import {useProfileQuery} from '#/state/queries/profile' import {useProfileQuery} from '#/state/queries/profile'
import {useResolveDidQuery} from '#/state/queries/resolve-uri' import {useResolveDidQuery} from '#/state/queries/resolve-uri'
import {useAgent, useSession} from '#/state/session' import {useAgent, useSession} from '#/state/session'
import {useSetMinimalShellMode} from '#/state/shell'
import {ProfileFeedgens} from '#/view/com/feeds/ProfileFeedgens' import {ProfileFeedgens} from '#/view/com/feeds/ProfileFeedgens'
import {ProfileLists} from '#/view/com/lists/ProfileLists' import {ProfileLists} from '#/view/com/lists/ProfileLists'
import {PagerWithHeader} from '#/view/com/pager/PagerWithHeader' import {PagerWithHeader} from '#/view/com/pager/PagerWithHeader'
@@ -175,7 +174,6 @@ function ProfileScreenLoaded({
}) { }) {
const profile = useProfileShadow(profileUnshadowed) const profile = useProfileShadow(profileUnshadowed)
const {hasSession, currentAccount} = useSession() const {hasSession, currentAccount} = useSession()
const setMinimalShellMode = useSetMinimalShellMode()
const {openComposer} = useOpenComposer() const {openComposer} = useOpenComposer()
const navigation = useNavigation<NavigationProp>() const navigation = useNavigation<NavigationProp>()
const requireEmailVerification = useRequireEmailVerification() const requireEmailVerification = useRequireEmailVerification()
@@ -317,11 +315,10 @@ function ProfileScreenLoaded({
useFocusEffect( useFocusEffect(
useCallback(() => { useCallback(() => {
setMinimalShellMode(false)
return listenSoftReset(() => { return listenSoftReset(() => {
scrollSectionToTop(currentPage) scrollSectionToTop(currentPage)
}) })
}, [setMinimalShellMode, currentPage, scrollSectionToTop]), }, [currentPage, scrollSectionToTop]),
) )
// events // events
-10
View File
@@ -1,28 +1,18 @@
import {useCallback} from 'react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import { import {
type CommonNavigatorParams, type CommonNavigatorParams,
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {makeRecordUri} from '#/lib/strings/url-helpers' import {makeRecordUri} from '#/lib/strings/url-helpers'
import {useSetMinimalShellMode} from '#/state/shell'
import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy' import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy'
import * as Layout from '#/components/Layout' import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFeedLikedBy'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileFeedLikedBy'>
export const ProfileFeedLikedByScreen = ({route}: Props) => { export const ProfileFeedLikedByScreen = ({route}: Props) => {
const setMinimalShellMode = useSetMinimalShellMode()
const {name, rkey} = route.params const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.generator', rkey) const uri = makeRecordUri(name, 'app.bsky.feed.generator', rkey)
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen testID="postLikedByScreen"> <Layout.Screen testID="postLikedByScreen">
<Layout.Header.Outer> <Layout.Header.Outer>
-10
View File
@@ -1,8 +1,6 @@
import {useCallback} from 'react'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {HELP_DESK_URL} from '#/lib/constants' import {HELP_DESK_URL} from '#/lib/constants'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
@@ -11,7 +9,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {TextLink} from '#/view/com/util/Link' import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ViewHeader} from '#/view/com/util/ViewHeader' import {ViewHeader} from '#/view/com/util/ViewHeader'
@@ -21,15 +18,8 @@ import * as Layout from '#/components/Layout'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'Support'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'Support'>
export const SupportScreen = (_props: Props) => { export const SupportScreen = (_props: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const setMinimalShellMode = useSetMinimalShellMode()
const {_} = useLingui() const {_} = useLingui()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<ViewHeader title={_(msg`Support`)} /> <ViewHeader title={_(msg`Support`)} />
-10
View File
@@ -1,9 +1,7 @@
import {useCallback} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {msg} from '@lingui/core/macro' import {msg} from '@lingui/core/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {Trans} from '@lingui/react/macro' import {Trans} from '@lingui/react/macro'
import {useFocusEffect} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import { import {
@@ -11,7 +9,6 @@ import {
type NativeStackScreenProps, type NativeStackScreenProps,
} from '#/lib/routes/types' } from '#/lib/routes/types'
import {s} from '#/lib/styles' import {s} from '#/lib/styles'
import {useSetMinimalShellMode} from '#/state/shell'
import {TextLink} from '#/view/com/util/Link' import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text' import {Text} from '#/view/com/util/text/Text'
import {ScrollView} from '#/view/com/util/Views' import {ScrollView} from '#/view/com/util/Views'
@@ -21,15 +18,8 @@ import {ViewHeader} from '../com/util/ViewHeader'
type Props = NativeStackScreenProps<CommonNavigatorParams, 'TermsOfService'> type Props = NativeStackScreenProps<CommonNavigatorParams, 'TermsOfService'>
export const TermsOfServiceScreen = (_props: Props) => { export const TermsOfServiceScreen = (_props: Props) => {
const pal = usePalette('default') const pal = usePalette('default')
const setMinimalShellMode = useSetMinimalShellMode()
const {_} = useLingui() const {_} = useLingui()
useFocusEffect(
useCallback(() => {
setMinimalShellMode(false)
}, [setMinimalShellMode]),
)
return ( return (
<Layout.Screen> <Layout.Screen>
<ViewHeader title={_(msg`Terms of Service`)} /> <ViewHeader title={_(msg`Terms of Service`)} />