mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Compose pop-in/out now can work with non-id medias
Commented out for now to see if it really works The bug is due to valtio proxying the File object
This commit is contained in:
parent
8099fedf82
commit
21bdb51cd6
2 changed files with 45 additions and 34 deletions
15
src/app.jsx
15
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(() => {
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
});
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue