Note creator V2 styles

This commit is contained in:
2023-08-23 13:19:48 +01:00
parent d4bbd4e87d
commit fb29cfa952
16 changed files with 285 additions and 276 deletions

View File

@ -26,9 +26,10 @@ export function getPublicKey(privKey: HexKey) {
export async function openFile(): Promise<File | undefined> {
return new Promise(resolve => {
const elm = document.createElement("input");
let lock = false;
elm.type = "file";
const handleInput = (e: Event) => {
console.debug(e);
lock = true;
const elm = e.target as HTMLInputElement;
if ((elm.files?.length ?? 0) > 0) {
resolve(elm.files![0]);
@ -38,8 +39,19 @@ export async function openFile(): Promise<File | undefined> {
};
elm.onchange = e => handleInput(e);
elm.onblur = e => handleInput(e);
elm.click();
window.addEventListener(
"focus",
() => {
setTimeout(() => {
if (!lock) {
console.debug("FOCUS WINDOW UPLOAD");
resolve(undefined);
}
}, 300);
},
{ once: true }
);
});
}