diff --git a/src/screens/Profile/Header/Shell.tsx b/src/screens/Profile/Header/Shell.tsx index 26e9406883..925066d72e 100644 --- a/src/screens/Profile/Header/Shell.tsx +++ b/src/screens/Profile/Header/Shell.tsx @@ -55,8 +55,18 @@ let ProfileHeaderShell = ({ const modui = moderation.ui('avatar') if (profile.avatar && !(modui.blur && modui.noOverride)) { openLightbox({ - type: 'profile-image', - profile: profile, + images: [ + { + uri: profile.avatar, + thumbUri: profile.avatar, + dimensions: { + // It's fine if it's actually smaller but we know it's 1:1. + height: 1000, + width: 1000, + }, + }, + ], + index: 0, thumbDims: null, }) } diff --git a/src/state/lightbox.tsx b/src/state/lightbox.tsx index 53409e3ecf..cdebeeede4 100644 --- a/src/state/lightbox.tsx +++ b/src/state/lightbox.tsx @@ -1,16 +1,9 @@ import React from 'react' import type {MeasuredDimensions} from 'react-native-reanimated' -import {AppBskyActorDefs} from '@atproto/api' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {Dimensions} from '#/lib/media/types' -type ProfileImageLightbox = { - type: 'profile-image' - profile: AppBskyActorDefs.ProfileViewDetailed - thumbDims: null -} - type ImagesLightboxItem = { uri: string thumbUri: string @@ -18,15 +11,12 @@ type ImagesLightboxItem = { dimensions: Dimensions | null } -type ImagesLightbox = { - type: 'images' +type Lightbox = { images: ImagesLightboxItem[] thumbDims: MeasuredDimensions | null index: number } -type Lightbox = ProfileImageLightbox | ImagesLightbox - const LightboxContext = React.createContext<{ activeLightbox: Lightbox | null }>({ diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx index 23da86c659..9f4abf28f4 100644 --- a/src/view/com/lightbox/Lightbox.tsx +++ b/src/view/com/lightbox/Lightbox.tsx @@ -27,33 +27,11 @@ export function Lightbox() { if (!activeLightbox) { return null - } else if (activeLightbox.type === 'profile-image') { + } else { const opts = activeLightbox return ( } - /> - ) - } else if (activeLightbox.type === 'images') { - const opts = activeLightbox - return ( - ({...img}))} + images={opts.images} initialImageIndex={opts.index} thumbDims={opts.thumbDims} visible @@ -66,8 +44,6 @@ export function Lightbox() { )} /> ) - } else { - return null } } diff --git a/src/view/com/lightbox/Lightbox.web.tsx b/src/view/com/lightbox/Lightbox.web.tsx index 9a0fa5d331..2ba7d06cc5 100644 --- a/src/view/com/lightbox/Lightbox.web.tsx +++ b/src/view/com/lightbox/Lightbox.web.tsx @@ -38,24 +38,8 @@ export function Lightbox() { return null } - const initialIndex = - activeLightbox.type === 'images' ? activeLightbox.index : 0 - - let imgs: Img[] | undefined - if (activeLightbox.type === 'profile-image') { - const opts = activeLightbox - if (opts.profile.avatar) { - imgs = [{uri: opts.profile.avatar}] - } - } else if (activeLightbox.type === 'images') { - const opts = activeLightbox - imgs = opts.images - } - - if (!imgs) { - return null - } - + const initialIndex = activeLightbox.index + const imgs = activeLightbox.images return ( { openLightbox({ - type: 'images', images: items, index, thumbDims,