diff --git a/src/screens/Messages/components/MessageComposer.tsx b/src/screens/Messages/components/MessageComposer.tsx index e19dbc109e..8433da2ffd 100644 --- a/src/screens/Messages/components/MessageComposer.tsx +++ b/src/screens/Messages/components/MessageComposer.tsx @@ -145,8 +145,6 @@ export function MessageComposer({ return ( - {children} - - {IS_WEB && ( - - composerInternalApiRef.current?.insert(emoji.native) - } - nextFocusRef={() => - composerInternalApiRef.current?.input?.element - }> - - {({props, state, control}) => ( - - - - )} - - - - )} + {children} + + {IS_WEB && ( + + composerInternalApiRef.current?.insert(emoji.native) + } + nextFocusRef={() => + composerInternalApiRef.current?.input?.element + }> + + {({props, state, control}) => ( + + + + )} + + + + )} - { - if (facet.type === 'url' && isBskyPostUrl(facet.value)) { - setEmbed(facet.value) - } - }} - onRequestSubmit={req => { - if (req.platform === 'web' && req.shiftKey) return - req.nativeEvent.preventDefault() - handleSubmit() - }} - /> + { + if (facet.type === 'url' && isBskyPostUrl(facet.value)) { + setEmbed(facet.value) + } + }} + onRequestSubmit={req => { + if (req.platform === 'web' && req.shiftKey) return + req.nativeEvent.preventDefault() + handleSubmit() + }} + /> + diff --git a/src/screens/Messages/components/MessageInput.tsx b/src/screens/Messages/components/MessageInput.tsx index 6a1d62f336..f52bbbeb43 100644 --- a/src/screens/Messages/components/MessageInput.tsx +++ b/src/screens/Messages/components/MessageInput.tsx @@ -158,7 +158,6 @@ export function MessageInput({ return ( - {children} @@ -168,6 +167,7 @@ export function MessageInput({ style={[a.flex_1, a.rounded_xl, {minHeight: MIN_HEIGHT}]} tintColor={t.palette.contrast_50} fallbackStyle={[t.atoms.bg_contrast_50]}> + {children} () const embedFromParams = route.params.embed - const [embedUri, setEmbed] = useState(embedFromParams) + const [embedUri, setEmbedUri] = useState(embedFromParams) if (embedFromParams && embedUri !== embedFromParams) { - setEmbed(embedFromParams) + setEmbedUri(embedFromParams) } return { @@ -53,7 +53,7 @@ export function useMessageEmbed() { (embedUrl: string | undefined) => { if (!embedUrl) { navigation.setParams({embed: ''}) - setEmbed(undefined) + setEmbedUri(undefined) return } @@ -63,7 +63,7 @@ export function useMessageEmbed() { const [_0, user, _1, rkey] = url.split('/').filter(Boolean) const uri = makeRecordUri(user, 'app.bsky.feed.post', rkey) - setEmbed(uri) + setEmbedUri(uri) }, [embedFromParams, navigation], ), @@ -103,7 +103,7 @@ export function MessageInputEmbed({ setEmbed: (embedUrl: string | undefined) => void }) { const t = useTheme() - const {_} = useLingui() + const {t: l} = useLingui() const {data: post, status} = usePostQuery(embedUri) @@ -138,25 +138,29 @@ export function MessageInputEmbed({ return null } - let content = null + const onRemove = () => { + LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) + setEmbed(undefined) + } + switch (status) { - case 'pending': - content = ( - + case 'pending': { + return ( + - + ) - break - case 'error': - content = ( - - Could not fetch post - + } + case 'error': { + return ( + + + Could not fetch post + + ) - break - case 'success': + } + case 'success': { const itemUrip = new AtUri(post.uri) const itemHref = makeProfileLink(post.author, 'post', itemUrip.rkey) @@ -164,62 +168,95 @@ export function MessageInputEmbed({ return null } - content = ( + return ( - + a.mt_sm, + a.mx_sm, + ]}> + + + + - + {rt.text && ( - - - + )} ) - break + } } +} +function SimpleContainer({ + children, + onRemove, +}: { + children: React.ReactNode + onRemove?: () => void +}) { + const t = useTheme() + const {t: l} = useLingui() return ( - - {content} - + + {children} + {onRemove && ( + + )} ) }