mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-29 04:39:20 +03:00
This close window check is getting on my nerves
This commit is contained in:
parent
2b21c421d1
commit
0e1f4c527e
1 changed files with 19 additions and 5 deletions
|
@ -208,15 +208,20 @@ export default ({
|
||||||
const canClose = () => {
|
const canClose = () => {
|
||||||
const { value, dataset } = textareaRef.current;
|
const { value, dataset } = textareaRef.current;
|
||||||
|
|
||||||
// check for status and media attachments with IDs
|
// check for status and media attachments
|
||||||
const hasIDMediaAttachments =
|
const hasMediaAttachments = mediaAttachments.length > 0;
|
||||||
mediaAttachments.length > 0 &&
|
if (!value && !hasMediaAttachments) {
|
||||||
mediaAttachments.every((media) => media.id);
|
|
||||||
if (!value && hasIDMediaAttachments) {
|
|
||||||
console.log('canClose', { value, mediaAttachments });
|
console.log('canClose', { value, mediaAttachments });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if all media attachments have IDs
|
||||||
|
const hasIDMediaAttachments = mediaAttachments.every((media) => media.id);
|
||||||
|
if (hasIDMediaAttachments) {
|
||||||
|
console.log('canClose', { hasIDMediaAttachments });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// check if status contains only "@acct", if replying
|
// check if status contains only "@acct", if replying
|
||||||
const isSelf = replyToStatus?.account.id === currentAccount;
|
const isSelf = replyToStatus?.account.id === currentAccount;
|
||||||
const hasOnlyAcct =
|
const hasOnlyAcct =
|
||||||
|
@ -233,6 +238,15 @@ export default ({
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('canClose', {
|
||||||
|
value,
|
||||||
|
hasMediaAttachments,
|
||||||
|
hasIDMediaAttachments,
|
||||||
|
isSelf,
|
||||||
|
hasOnlyAcct,
|
||||||
|
sameWithSource,
|
||||||
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue