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={
|
replyToStatus={
|
||||||
typeof snapStates.showCompose !== 'boolean'
|
typeof snapStates.showCompose !== 'boolean'
|
||||||
? snapStates.showCompose.replyToStatus
|
? 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) => {
|
onClose={(results) => {
|
||||||
const { newStatus } = results || {};
|
const { newStatus } = results || {};
|
||||||
states.showCompose = false;
|
states.showCompose = false;
|
||||||
|
window.__COMPOSE__ = null;
|
||||||
if (newStatus) {
|
if (newStatus) {
|
||||||
states.reloadStatusPage++;
|
states.reloadStatusPage++;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -476,21 +476,21 @@ function Compose({
|
||||||
disabled={uiState === 'loading'}
|
disabled={uiState === 'loading'}
|
||||||
onClick={() => {
|
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
|
// 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 =
|
// const containNonIDMediaAttachments =
|
||||||
mediaAttachments.length > 0 &&
|
// mediaAttachments.length > 0 &&
|
||||||
mediaAttachments.some((media) => !media.id);
|
// mediaAttachments.some((media) => !media.id);
|
||||||
if (containNonIDMediaAttachments) {
|
// if (containNonIDMediaAttachments) {
|
||||||
const yes = confirm(
|
// 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?',
|
// '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) {
|
// if (!yes) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
const mediaAttachmentsWithIDs = mediaAttachments.filter(
|
// const mediaAttachmentsWithIDs = mediaAttachments.filter(
|
||||||
(media) => media.id,
|
// (media) => media.id,
|
||||||
);
|
// );
|
||||||
|
|
||||||
const newWin = openCompose({
|
const newWin = openCompose({
|
||||||
editStatus,
|
editStatus,
|
||||||
|
@ -502,7 +502,7 @@ function Compose({
|
||||||
language,
|
language,
|
||||||
sensitive,
|
sensitive,
|
||||||
poll,
|
poll,
|
||||||
mediaAttachments: mediaAttachmentsWithIDs,
|
mediaAttachments,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -537,17 +537,17 @@ function Compose({
|
||||||
disabled={uiState === 'loading'}
|
disabled={uiState === 'loading'}
|
||||||
onClick={() => {
|
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
|
// 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 =
|
// const containNonIDMediaAttachments =
|
||||||
mediaAttachments.length > 0 &&
|
// mediaAttachments.length > 0 &&
|
||||||
mediaAttachments.some((media) => !media.id);
|
// mediaAttachments.some((media) => !media.id);
|
||||||
if (containNonIDMediaAttachments) {
|
// if (containNonIDMediaAttachments) {
|
||||||
const yes = confirm(
|
// 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?',
|
// '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) {
|
// if (!yes) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!window.opener) {
|
if (!window.opener) {
|
||||||
alert('Looks like you closed the parent window.');
|
alert('Looks like you closed the parent window.');
|
||||||
|
@ -561,13 +561,13 @@ function Compose({
|
||||||
if (!yes) return;
|
if (!yes) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mediaAttachmentsWithIDs = mediaAttachments.filter(
|
// const mediaAttachmentsWithIDs = mediaAttachments.filter(
|
||||||
(media) => media.id,
|
// (media) => media.id,
|
||||||
);
|
// );
|
||||||
|
|
||||||
onClose({
|
onClose({
|
||||||
fn: () => {
|
fn: () => {
|
||||||
window.opener.__STATES__.showCompose = {
|
const passData = {
|
||||||
editStatus,
|
editStatus,
|
||||||
replyToStatus,
|
replyToStatus,
|
||||||
draftStatus: {
|
draftStatus: {
|
||||||
|
@ -577,9 +577,11 @@ function Compose({
|
||||||
language,
|
language,
|
||||||
sensitive,
|
sensitive,
|
||||||
poll,
|
poll,
|
||||||
mediaAttachments: mediaAttachmentsWithIDs,
|
mediaAttachments,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
window.opener.__COMPOSE__ = passData;
|
||||||
|
window.opener.__STATES__.showCompose = true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue