|
@ -5,6 +5,7 @@ |
|
|
import { |
|
|
import { |
|
|
addToEmbeds, |
|
|
addToEmbeds, |
|
|
embeddedToBlob, |
|
|
embeddedToBlob, |
|
|
|
|
|
externalDispatch, |
|
|
fireNotification, |
|
|
fireNotification, |
|
|
getFileFromHydrus, |
|
|
getFileFromHydrus, |
|
|
uploadFiles, |
|
|
uploadFiles, |
|
@ -24,11 +25,7 @@ |
|
|
let currentEmbed: { file: File } | undefined; |
|
|
let currentEmbed: { file: File } | undefined; |
|
|
|
|
|
|
|
|
function restore() { |
|
|
function restore() { |
|
|
document.dispatchEvent( |
|
|
externalDispatch("QRSetFile", { file: original }); |
|
|
new CustomEvent("QRSetFile", { |
|
|
|
|
|
detail: { file: original }, |
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// This is an event to signal a change in the container file |
|
|
// This is an event to signal a change in the container file |
|
@ -36,7 +33,9 @@ |
|
|
|
|
|
|
|
|
const isSame = (a: File | null, b: File | null) => { |
|
|
const isSame = (a: File | null, b: File | null) => { |
|
|
if (a == null || b == null) return false; |
|
|
if (a == null || b == null) return false; |
|
|
return (["size", "name", "lastModified"] as const).every((e) => a[e] == b[e]); |
|
|
return (["size", "name", "lastModified"] as const).every( |
|
|
|
|
|
(e) => a[e] == b[e] |
|
|
|
|
|
); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
document.addEventListener("PEEFile", async (e) => { |
|
|
document.addEventListener("PEEFile", async (e) => { |
|
@ -108,11 +107,7 @@ |
|
|
currentEmbed = { |
|
|
currentEmbed = { |
|
|
file: new File([buff], file.name, { type }), |
|
|
file: new File([buff], file.name, { type }), |
|
|
} as { file: File }; |
|
|
} as { file: File }; |
|
|
document.dispatchEvent( |
|
|
externalDispatch("QRSetFile", currentEmbed); |
|
|
new CustomEvent("QRSetFile", { |
|
|
|
|
|
detail: currentEmbed, |
|
|
|
|
|
}) |
|
|
|
|
|
); |
|
|
|
|
|
fireNotification( |
|
|
fireNotification( |
|
|
"success", |
|
|
"success", |
|
|
`File${links.length > 1 ? "s" : ""} successfully embedded!` |
|
|
`File${links.length > 1 ? "s" : ""} successfully embedded!` |
|
|