fix: deleteWithUndo uses _reloadAfterAction() instead of manual tree manipulation
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

Replaced fragile _removeFromTree() + displayTree spread (which had Alpine
reactivity issues) with a clean _reloadAfterAction() call that reloads the
tree from the API. This is the same approach used by doDelete() and
doRename(), which work reliably. _reloadAfterAction also triggers the
sidebar refresh via window.appState.refreshSidebarTree().
This commit is contained in:
2026-07-16 09:45:45 -04:00
parent 6e4adaad8b
commit 30e1879ac2
+4 -11
View File
@@ -1209,23 +1209,16 @@ window._wsInitData = (function() {
this.undoItemId = node.db_id || node.id;
this.undoMessage = 'Deleted "' + (node.name || 'item') + '"';
this.undoVisible = true;
// Soft-delete: actually delete after timeout
// Delete via API
var r = await fetch('/api/local-workspace/items/' + this.undoItemId, { method:'DELETE' });
if (!r.ok) { this.undoVisible = false; return; }
// Remove from tree immediately
this._removeFromTree(this.tree, this.undoItemId);
if (!this.searchQuery && !this.filterType && !this.sortBy) this.displayTree = [...this.tree];
else if (this.sortBy) this.doSort();
else this.doFilter();
// Auto-dismiss + permanent after 5s
// Reload from API for reliability (sidebar refresh handled by _reloadAfterAction)
this._reloadAfterAction();
// Auto-dismiss undo banner after 5s
this.undoTimeout = setTimeout(function() {
self.undoVisible = false;
self.undoItemId = null;
}, 5000);
// Directly refresh sidebar tree
if (window.appState && window.appState.refreshSidebarTree) {
window.appState.refreshSidebarTree();
}
},
undoDelete() {
if (this.undoTimeout) clearTimeout(this.undoTimeout);