diff --git a/app/templates/base.html b/app/templates/base.html
index 9305259..06e84e9 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -511,6 +511,9 @@
function appState() {
return {
+ init() {
+ window.appState = this;
+ },
sidebarCollapsed: false,
mobileSidebarOpen: false,
showInvite: true,
@@ -602,6 +605,9 @@
if (r.ok) {
self.refreshSidebarTree();
document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed'));
+ if (window._wsData && window._wsData._reloadAfterAction) {
+ window._wsData._reloadAfterAction();
+ }
}
});
}
@@ -933,7 +939,7 @@
body: JSON.stringify({ name: name.trim(), type: 'folder' })
})
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
- .then(() => { this.refreshSidebarTree(); document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed')); })
+ .then(() => { this.refreshSidebarTree(); document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed')); if (window._wsData && window._wsData._reloadAfterAction) { window._wsData._reloadAfterAction(); } })
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
},
deleteWorkspacePage(pageId, skipConfirm) {
@@ -943,7 +949,7 @@
headers: { 'X-CSRF-Token': this.getCsrfToken() }
})
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
- .then(() => { this.refreshSidebarTree(); document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed')); })
+ .then(() => { this.refreshSidebarTree(); document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed')); if (window._wsData && window._wsData._reloadAfterAction) { window._wsData._reloadAfterAction(); } })
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
},
@@ -991,6 +997,10 @@
.then(() => {
this.refreshSidebarTree();
document.dispatchEvent(new CustomEvent('flowdeck:workspace-changed'));
+ // Also directly notify main content if on local-workspace page
+ if (window._wsData && window._wsData._reloadAfterAction) {
+ window._wsData._reloadAfterAction();
+ }
})
.catch(err => { this.toast('Move failed: ' + err.message, 'error'); });
},
diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html
index 7515896..fb502af 100644
--- a/app/templates/local_workspace.html
+++ b/app/templates/local_workspace.html
@@ -498,10 +498,6 @@ window._wsInitData = (function() {
var self = this;
window.addEventListener('online', function() { self.online = true; });
window.addEventListener('offline', function() { self.online = false; });
- // Listen for workspace changes from sidebar context menu
- document.addEventListener('flowdeck:workspace-changed', function() {
- self._reloadAfterAction();
- });
// Load workspace tags
this.loadWorkspaceTags();
} catch(e) { console.error('Tree load error:', e); this.loaded = true; }
@@ -1115,8 +1111,10 @@ window._wsInitData = (function() {
_reloadAfterAction() {
this._saveExpandedState();
this._loadFolder(this.currentFolder);
- // Notify sidebar to refresh its tree
- document.dispatchEvent(new CustomEvent('flowdeck:sidebar-refresh'));
+ // Directly refresh sidebar tree
+ if (window.appState && window.appState.refreshSidebarTree) {
+ window.appState.refreshSidebarTree();
+ }
},
// ── Inline Rename ──
@@ -1224,8 +1222,10 @@ window._wsInitData = (function() {
self.undoVisible = false;
self.undoItemId = null;
}, 5000);
- // Notify sidebar to refresh its tree
- document.dispatchEvent(new CustomEvent('flowdeck:sidebar-refresh'));
+ // Directly refresh sidebar tree
+ if (window.appState && window.appState.refreshSidebarTree) {
+ window.appState.refreshSidebarTree();
+ }
},
undoDelete() {
if (this.undoTimeout) clearTimeout(this.undoTimeout);
@@ -1563,8 +1563,10 @@ window._wsInitData = (function() {
this.doFilter();
}
this._saveExpandedState();
- // Notify sidebar to refresh its tree
- document.dispatchEvent(new CustomEvent('flowdeck:sidebar-refresh'));
+ // Directly refresh sidebar tree
+ if (window.appState && window.appState.refreshSidebarTree) {
+ window.appState.refreshSidebarTree();
+ }
}
},