fix: deleteWithUndo uses _reloadAfterAction() instead of manual tree manipulation
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user