diff --git a/src/app.jsx b/src/app.jsx index 86cf33e5..034bc929 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -237,13 +237,22 @@ function App() { replyToStatus={ typeof snapStates.showCompose !== 'boolean' ? snapStates.showCompose.replyToStatus - : null + : window.__COMPOSE__?.replyToStatus || null + } + editStatus={ + states.showCompose?.editStatus || + window.__COMPOSE__?.editStatus || + null + } + draftStatus={ + states.showCompose?.draftStatus || + window.__COMPOSE__?.draftStatus || + null } - editStatus={states.showCompose?.editStatus || null} - draftStatus={states.showCompose?.draftStatus || null} onClose={(results) => { const { newStatus } = results || {}; states.showCompose = false; + window.__COMPOSE__ = null; if (newStatus) { states.reloadStatusPage++; setTimeout(() => { diff --git a/src/components/compose.jsx b/src/components/compose.jsx index ac059ce5..96b19b24 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -476,21 +476,21 @@ function Compose({ disabled={uiState === 'loading'} onClick={() => { // If there are non-ID media attachments (not yet uploaded), show confirmation dialog because they are not going to be passed to the new window - const containNonIDMediaAttachments = - mediaAttachments.length > 0 && - mediaAttachments.some((media) => !media.id); - if (containNonIDMediaAttachments) { - const yes = confirm( - 'You have media attachments that are not yet uploaded. Opening a new window will discard them and you will need to re-attach them. Are you sure you want to continue?', - ); - if (!yes) { - return; - } - } + // const containNonIDMediaAttachments = + // mediaAttachments.length > 0 && + // mediaAttachments.some((media) => !media.id); + // if (containNonIDMediaAttachments) { + // const yes = confirm( + // 'You have media attachments that are not yet uploaded. Opening a new window will discard them and you will need to re-attach them. Are you sure you want to continue?', + // ); + // if (!yes) { + // return; + // } + // } - const mediaAttachmentsWithIDs = mediaAttachments.filter( - (media) => media.id, - ); + // const mediaAttachmentsWithIDs = mediaAttachments.filter( + // (media) => media.id, + // ); const newWin = openCompose({ editStatus, @@ -502,7 +502,7 @@ function Compose({ language, sensitive, poll, - mediaAttachments: mediaAttachmentsWithIDs, + mediaAttachments, }, }); @@ -537,17 +537,17 @@ function Compose({ disabled={uiState === 'loading'} onClick={() => { // If there are non-ID media attachments (not yet uploaded), show confirmation dialog because they are not going to be passed to the new window - const containNonIDMediaAttachments = - mediaAttachments.length > 0 && - mediaAttachments.some((media) => !media.id); - if (containNonIDMediaAttachments) { - const yes = confirm( - 'You have media attachments that are not yet uploaded. Opening a new window will discard them and you will need to re-attach them. Are you sure you want to continue?', - ); - if (!yes) { - return; - } - } + // const containNonIDMediaAttachments = + // mediaAttachments.length > 0 && + // mediaAttachments.some((media) => !media.id); + // if (containNonIDMediaAttachments) { + // const yes = confirm( + // 'You have media attachments that are not yet uploaded. Opening a new window will discard them and you will need to re-attach them. Are you sure you want to continue?', + // ); + // if (!yes) { + // return; + // } + // } if (!window.opener) { alert('Looks like you closed the parent window.'); @@ -561,13 +561,13 @@ function Compose({ if (!yes) return; } - const mediaAttachmentsWithIDs = mediaAttachments.filter( - (media) => media.id, - ); + // const mediaAttachmentsWithIDs = mediaAttachments.filter( + // (media) => media.id, + // ); onClose({ fn: () => { - window.opener.__STATES__.showCompose = { + const passData = { editStatus, replyToStatus, draftStatus: { @@ -577,9 +577,11 @@ function Compose({ language, sensitive, poll, - mediaAttachments: mediaAttachmentsWithIDs, + mediaAttachments, }, }; + window.opener.__COMPOSE__ = passData; + window.opener.__STATES__.showCompose = true; }, }); }}