mirror of
https://github.com/HeyPuter/puter.git
synced 2026-11-05 21:46:51 +00:00
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:
1 parent
e4dfb51ea3
commit
222d7eb744
1 file changed
+9
-4
@@ -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--;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user