diff options
Diffstat (limited to 'src/view')
-rw-r--r-- | src/view/com/util/images/AutoSizedImage.tsx | 4 | ||||
-rw-r--r-- | src/view/com/util/post-embeds/index.tsx | 9 | ||||
-rw-r--r-- | src/view/screens/Profile.tsx | 5 | ||||
-rw-r--r-- | src/view/shell/desktop/LeftNav.tsx | 23 |
4 files changed, 32 insertions, 9 deletions
diff --git a/src/view/com/util/images/AutoSizedImage.tsx b/src/view/com/util/images/AutoSizedImage.tsx index da2f7ab45..035e29c25 100644 --- a/src/view/com/util/images/AutoSizedImage.tsx +++ b/src/view/com/util/images/AutoSizedImage.tsx @@ -11,6 +11,7 @@ const MAX_ASPECT_RATIO = 5 // 5/1 interface Props { alt?: string uri: string + dimensionsHint?: Dimensions onPress?: () => void onLongPress?: () => void onPressIn?: () => void @@ -21,6 +22,7 @@ interface Props { export function AutoSizedImage({ alt, uri, + dimensionsHint, onPress, onLongPress, onPressIn, @@ -29,7 +31,7 @@ export function AutoSizedImage({ }: Props) { const store = useStores() const [dim, setDim] = React.useState<Dimensions | undefined>( - store.imageSizes.get(uri), + dimensionsHint || store.imageSizes.get(uri), ) const [aspectRatio, setAspectRatio] = React.useState<number>( dim ? calc(dim) : 1, diff --git a/src/view/com/util/post-embeds/index.tsx b/src/view/com/util/post-embeds/index.tsx index ce6da4a1b..2d79eed8f 100644 --- a/src/view/com/util/post-embeds/index.tsx +++ b/src/view/com/util/post-embeds/index.tsx @@ -93,7 +93,11 @@ export function PostEmbeds({ const {images} = embed if (images.length > 0) { - const items = embed.images.map(img => ({uri: img.fullsize, alt: img.alt})) + const items = embed.images.map(img => ({ + uri: img.fullsize, + alt: img.alt, + aspectRatio: img.aspectRatio, + })) const openLightbox = (index: number) => { store.shell.openLightbox(new ImagesLightbox(items, index)) } @@ -104,12 +108,13 @@ export function PostEmbeds({ } if (images.length === 1) { - const {alt, thumb} = images[0] + const {alt, thumb, aspectRatio} = images[0] return ( <View style={[styles.imagesContainer, style]}> <AutoSizedImage alt={alt} uri={thumb} + dimensionsHint={aspectRatio} onPress={() => openLightbox(0)} onPressIn={() => onPressIn(0)} style={[ diff --git a/src/view/screens/Profile.tsx b/src/view/screens/Profile.tsx index efcb588f6..596bda57e 100644 --- a/src/view/screens/Profile.tsx +++ b/src/view/screens/Profile.tsx @@ -91,7 +91,10 @@ export const ProfileScreen = withAuthRequired( const onPressCompose = React.useCallback(() => { track('ProfileScreen:PressCompose') const mention = - uiState.profile.handle === store.me.handle ? '' : uiState.profile.handle + uiState.profile.handle === store.me.handle || + uiState.profile.handle === 'handle.invalid' + ? undefined + : uiState.profile.handle store.shell.openComposer({mention}) }, [store, track, uiState]) const onSelectView = React.useCallback( diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index b19d5e8ab..fb3d66462 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -185,20 +185,33 @@ function ComposeBtn() { const {getState} = useNavigation() const {isTablet} = useWebMediaQueries() - const getProfileHandle = () => { + const getProfileHandle = async () => { const {routes} = getState() const currentRoute = routes[routes.length - 1] + if (currentRoute.name === 'Profile') { - const {name: handle} = + let handle: string | undefined = ( currentRoute.params as CommonNavigatorParams['Profile'] - if (handle === store.me.handle) return undefined + ).name + + if (handle.startsWith('did:')) { + const cached = await store.profiles.cache.get(handle) + const profile = cached ? cached.data : undefined + // if we can't resolve handle, set to undefined + handle = profile?.handle || undefined + } + + if (!handle || handle === store.me.handle || handle === 'handle.invalid') + return undefined + return handle } + return undefined } - const onPressCompose = () => - store.shell.openComposer({mention: getProfileHandle()}) + const onPressCompose = async () => + store.shell.openComposer({mention: await getProfileHandle()}) if (isTablet) { return null |