Factor lightbox out into hook/context (#1919)
This commit is contained in:
parent
03b20c70e4
commit
e749f2f3a5
10 changed files with 152 additions and 104 deletions
|
@ -17,7 +17,6 @@ import {useLingui} from '@lingui/react'
|
|||
import {NavigationProp} from 'lib/routes/types'
|
||||
import {isNative} from 'platform/detection'
|
||||
import {BlurView} from '../util/BlurView'
|
||||
import {ProfileImageLightbox} from 'state/models/ui/shell'
|
||||
import * as Toast from '../util/Toast'
|
||||
import {LoadingPlaceholder} from '../util/LoadingPlaceholder'
|
||||
import {Text} from '../util/text/Text'
|
||||
|
@ -30,8 +29,8 @@ import {formatCount} from '../util/numeric/format'
|
|||
import {NativeDropdown, DropdownItem} from '../util/forms/NativeDropdown'
|
||||
import {Link} from '../util/Link'
|
||||
import {ProfileHeaderSuggestedFollows} from './ProfileHeaderSuggestedFollows'
|
||||
import {useStores} from 'state/index'
|
||||
import {useModalControls} from '#/state/modals'
|
||||
import {useLightboxControls, ProfileImageLightbox} from '#/state/lightbox'
|
||||
import {
|
||||
useProfileFollowMutation,
|
||||
useProfileUnfollowMutation,
|
||||
|
@ -115,10 +114,10 @@ function ProfileHeaderLoaded({
|
|||
}: Props) {
|
||||
const pal = usePalette('default')
|
||||
const palInverted = usePalette('inverted')
|
||||
const store = useStores()
|
||||
const {currentAccount} = useSession()
|
||||
const {_} = useLingui()
|
||||
const {openModal} = useModalControls()
|
||||
const {openLightbox} = useLightboxControls()
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
const {track} = useAnalytics()
|
||||
const invalidHandle = isInvalidHandle(profile.handle)
|
||||
|
@ -151,9 +150,9 @@ function ProfileHeaderLoaded({
|
|||
profile.avatar &&
|
||||
!(moderation.avatar.blur && moderation.avatar.noOverride)
|
||||
) {
|
||||
store.shell.openLightbox(new ProfileImageLightbox(profile))
|
||||
openLightbox(new ProfileImageLightbox(profile))
|
||||
}
|
||||
}, [store, profile, moderation])
|
||||
}, [openLightbox, profile, moderation])
|
||||
|
||||
const onPressFollow = React.useCallback(async () => {
|
||||
if (profile.viewer?.following) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {useStores} from 'state/index'
|
|||
import {NavigationProp} from 'lib/routes/types'
|
||||
import {BACK_HITSLOP} from 'lib/constants'
|
||||
import {isNative} from 'platform/detection'
|
||||
import {ImagesLightbox} from 'state/models/ui/shell'
|
||||
import {useLightboxControls, ImagesLightbox} from '#/state/lightbox'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {msg} from '@lingui/macro'
|
||||
import {useSetDrawerOpen} from '#/state/shell'
|
||||
|
@ -50,6 +50,7 @@ export const ProfileSubpageHeader = observer(function HeaderImpl({
|
|||
const navigation = useNavigation<NavigationProp>()
|
||||
const {_} = useLingui()
|
||||
const {isMobile} = useWebMediaQueries()
|
||||
const {openLightbox} = useLightboxControls()
|
||||
const pal = usePalette('default')
|
||||
const canGoBack = navigation.canGoBack()
|
||||
|
||||
|
@ -69,9 +70,9 @@ export const ProfileSubpageHeader = observer(function HeaderImpl({
|
|||
if (
|
||||
avatar // TODO && !(view.moderation.avatar.blur && view.moderation.avatar.noOverride)
|
||||
) {
|
||||
store.shell.openLightbox(new ImagesLightbox([{uri: avatar}], 0))
|
||||
openLightbox(new ImagesLightbox([{uri: avatar}], 0))
|
||||
}
|
||||
}, [store, avatar])
|
||||
}, [openLightbox, avatar])
|
||||
|
||||
return (
|
||||
<CenteredView style={pal.view}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue