From 162fc7ad077115a6e914949e6757183351b3eed3 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 11 Jan 2023 17:07:47 +0800 Subject: [PATCH] Pass UID across composer popups --- src/components/compose.jsx | 10 +++++++--- src/compose.jsx | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 6dd0026..e2e7b94 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -81,8 +81,8 @@ function Compose({ }) { console.warn('RENDER COMPOSER'); const [uiState, setUIState] = useState('default'); - const UID = useMemo(() => uid(), []); - console.log('Compose UID', UID); + const UID = useRef(uid()); + console.log('Compose UID', UID.current); const currentAccount = getCurrentAccount(); const currentAccountInfo = currentAccount.info; @@ -178,6 +178,7 @@ function Compose({ } if (draftStatus) { const { + uid, status, spoilerText, visibility, @@ -186,6 +187,7 @@ function Compose({ poll, mediaAttachments, } = draftStatus; + UID.current = uid; const composablePoll = !!poll?.options && { ...poll, options: poll.options.map((o) => o?.title || o), @@ -384,6 +386,7 @@ function Compose({ editStatus, replyToStatus, draftStatus: { + uid: UID.current, status: textareaRef.current.value, spoilerText: spoilerTextRef.current.value, visibility, @@ -459,6 +462,7 @@ function Compose({ editStatus, replyToStatus, draftStatus: { + uid: UID.current, status: textareaRef.current.value, spoilerText: spoilerTextRef.current.value, visibility, @@ -630,7 +634,7 @@ function Compose({ ); } else { newStatus = await masto.v1.statuses.create(params, { - idempotencyKey: UID, + idempotencyKey: UID.current, }); } setUIState('default'); diff --git a/src/compose.jsx b/src/compose.jsx index 5b77f73..8c5e0a4 100644 --- a/src/compose.jsx +++ b/src/compose.jsx @@ -74,6 +74,8 @@ function App() { ); } + console.debug('OPEN COMPOSE'); + return (