fix(dashboard): show items added elsewhere while New › Web Link prompts

The New menu's create wrapper suppressed item.added for as long as it ran,
which for Web Link includes its URL prompt, so files added to the folder
meanwhile never appeared. It now counts only from the actual create. A
create that fails now says so instead of failing silently.
This commit is contained in:
Nariman Jelveh committed 2026-10-23 14:13:06 -07:00
1 parent e4dfb51ea3
commit 222d7eb744
1 file changed
+9 -4
+9 -4
View File
@@ -4553,15 +4553,20 @@ const TabFiles = {
const wrapWithDashboardRename = (originalOnClick) => {
return async () => {
$('.context-menu').remove();
_this._creatingItem++;
// Temporarily intercept create_file to capture the upload promise
let uploadPromise = null;
const origCreateFile = window.create_file;
window.create_file = (options) => {
// Counted from here, not from the click: Web Link
// waits on a prompt first, and other items added
// to the folder meanwhile must still show up.
_this._creatingItem++;
const content = options.content ? [options.content] : [];
uploadPromise = puter.fs.upload(new File(content, options.name), options.dirname);
return uploadPromise;
// A failure is reported once, below, not again by
// a caller that awaits this.
return uploadPromise.catch(() => undefined);
};
try {
@@ -4598,10 +4603,10 @@ const TabFiles = {
}
}
} catch ( err ) {
// File creation failed silently
UIAlert(err?.message ?? String(err));
} finally {
window.create_file = origCreateFile;
_this._creatingItem--;
if ( uploadPromise ) _this._creatingItem--;
}
};
};