From df6686077a70fd441cc064d5e13c4da5c08f3699 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 3 Jun 2024 15:16:17 -0500 Subject: [PATCH] Use local state for embed, style tweaks --- .../Conversation/MessageInputEmbed.tsx | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/screens/Messages/Conversation/MessageInputEmbed.tsx b/src/screens/Messages/Conversation/MessageInputEmbed.tsx index b2013a5730..285b484fb1 100644 --- a/src/screens/Messages/Conversation/MessageInputEmbed.tsx +++ b/src/screens/Messages/Conversation/MessageInputEmbed.tsx @@ -39,11 +39,16 @@ export function useMessageEmbed() { const navigation = useNavigation() const embedFromParams = route.params.embed - const [embedUri, setEmbed] = useState(embedFromParams) + const [embedUri, setEmbed] = useState(() => { + return embedFromParams + }) - if (embedFromParams && embedUri !== embedFromParams) { - setEmbed(embedFromParams) - } + React.useEffect(() => { + // remove from nav state, use local component state only + if (embedUri === embedFromParams) { + navigation.setParams({embed: ''}) + } + }, [embedUri, embedFromParams, navigation]) return { embedUri, @@ -141,7 +146,16 @@ export function MessageInputEmbed({ case 'pending': content = ( + style={[ + a.flex_1, + {minHeight: 64}, + t.atoms.border_contrast_low, + a.rounded_md, + a.border, + a.mb_sm, + a.justify_center, + a.align_center, + ]}> ) @@ -149,8 +163,16 @@ export function MessageInputEmbed({ case 'error': content = ( - Could not fetch post + style={[ + a.flex_1, + {minHeight: 64}, + a.justify_center, + a.align_center, + a.mb_sm, + a.rounded_md, + t.atoms.bg_contrast_25, + ]}> + Could not fetch post ) break