Show wait cursor while loading a file

This commit is contained in:
Skyler Lehmkuhl 2025-01-23 16:41:00 -05:00
parent ca69813a5c
commit 065e6eb99e
1 changed files with 14 additions and 4 deletions

View File

@ -4492,6 +4492,7 @@ async function saveAs() {
} }
async function _open(path, returnJson = false) { async function _open(path, returnJson = false) {
document.body.style.cursor = "wait"
closeDialog(); closeDialog();
try { try {
const contents = await readTextFile(path); const contents = await readTextFile(path);
@ -4501,6 +4502,7 @@ async function _open(path, returnJson = false) {
title: "Load error", title: "Load error",
kind: "error", kind: "error",
}); });
document.body.style.cursor = "default"
return; return;
} }
if (file.version >= minFileVersion) { if (file.version >= minFileVersion) {
@ -4511,6 +4513,7 @@ async function _open(path, returnJson = false) {
"Could not import from this file. Re-save it with a current version of Lightningbeam.", "Could not import from this file. Re-save it with a current version of Lightningbeam.",
); );
} }
document.body.style.cursor = "default"
return file.json; return file.json;
} else { } else {
_newFile(file.width, file.height, file.fps); _newFile(file.width, file.height, file.fps);
@ -4519,6 +4522,7 @@ async function _open(path, returnJson = false) {
title: "Parse error", title: "Parse error",
kind: "error", kind: "error",
}); });
document.body.style.cursor = "default"
return; return;
} }
@ -4531,6 +4535,7 @@ async function _open(path, returnJson = false) {
`Invalid action ${action.name}. File may be corrupt.`, `Invalid action ${action.name}. File may be corrupt.`,
{ title: "Error", kind: "error" }, { title: "Error", kind: "error" },
); );
document.body.style.cursor = "default"
return; return;
} }
@ -4735,6 +4740,7 @@ async function _open(path, returnJson = false) {
); );
} }
} }
document.body.style.cursor = "default"
} }
async function open() { async function open() {
@ -4751,7 +4757,8 @@ async function open() {
}); });
console.log(path); console.log(path);
if (path) { if (path) {
_open(path); document.body.style.cursor = "wait"
setTimeout(()=>_open(path),10);
} }
} }
@ -6770,7 +6777,8 @@ async function startup() {
createNewFileDialog(_newFile, _open, config); createNewFileDialog(_newFile, _open, config);
if (!window.openedFiles?.length) { if (!window.openedFiles?.length) {
if (config.reopenLastSession && config.recentFiles?.length) { if (config.reopenLastSession && config.recentFiles?.length) {
_open(config.recentFiles[0]) document.body.style.cursor = "wait"
setTimeout(()=>_open(config.recentFiles[0]), 10)
} else { } else {
showNewFileDialog(config); showNewFileDialog(config);
} }
@ -7908,7 +7916,8 @@ async function renderMenu() {
text: file, text: file,
enabled: true, enabled: true,
action: () => { action: () => {
_open(file); document.body.style.cursor = "wait"
setTimeout(()=>_open(file),10);
}, },
}); });
}); });
@ -8393,7 +8402,8 @@ function renderAll() {
renderAll(); renderAll();
if (window.openedFiles?.length>0) { if (window.openedFiles?.length>0) {
_open(window.openedFiles[0]) document.body.style.cursor = "wait"
setTimeout(()=>_open(window.openedFiles[0]),10)
for (let i=1; i<window.openedFiles.length; i++) { for (let i=1; i<window.openedFiles.length; i++) {
newWindow(window.openedFiles[i]) newWindow(window.openedFiles[i])
} }