diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html
index 504474f..128e24e 100644
--- a/app/templates/local_workspace.html
+++ b/app/templates/local_workspace.html
@@ -300,7 +300,10 @@ document.addEventListener('alpine:init', function() {
newName:'',
parentFolder:null,
target:null,
- expanded: {},
+ expanded: (function() {
+ try { return JSON.parse(localStorage.getItem('fd_ws_expanded') || '{}'); }
+ catch(e) { return {}; }
+ })(),
currentFolder: {{ current_folder_id }},
searchQuery: '',
@@ -429,6 +432,7 @@ document.addEventListener('alpine:init', function() {
toggleExpand(id, btn) {
this.expanded[id] = !(this.expanded[id] || false);
this.expanded = Object.assign({}, this.expanded);
+ this._saveExpandedState();
// For renderChildren static HTML: toggle chevron + sibling
if (btn) {
btn.classList.toggle('open', this.expanded[id]);
@@ -447,9 +451,19 @@ document.addEventListener('alpine:init', function() {
},
navigateToFolder(id) {
+ this._saveExpandedState();
window.location = '/local-workspace?folder=' + id;
},
+ _saveExpandedState() {
+ try { localStorage.setItem('fd_ws_expanded', JSON.stringify(this.expanded)); }
+ catch(e) {}
+ },
+ _reloadAfterAction() {
+ this._saveExpandedState();
+ this._reloadAfterAction();
+ },
+
// ── Expand / Collapse all ──
expandAll() {
var self = this;
@@ -597,7 +611,7 @@ document.addEventListener('alpine:init', function() {
this.showCreate = false;
this.parentFolder = null;
this.newName = '';
- window.location.reload();
+ this._reloadAfterAction();
}
},
@@ -622,7 +636,7 @@ document.addEventListener('alpine:init', function() {
headers:{'Content-Type':'application/json'},
body:JSON.stringify({name:n})
});
- if (r.ok) { window.location.reload(); }
+ if (r.ok) { this._reloadAfterAction(); }
},
startDelete(node) {
@@ -633,7 +647,7 @@ document.addEventListener('alpine:init', function() {
async doDelete() {
if (!this.target) return;
var r = await fetch('/api/local-workspace/items/'+this.target.db_id, { method:'DELETE' });
- if (r.ok) { window.location.reload(); }
+ if (r.ok) { this._reloadAfterAction(); }
},
// ── Drag & Drop ──
@@ -829,7 +843,7 @@ document.addEventListener('alpine:init', function() {
body: JSON.stringify(body)
});
if (r.ok) {
- window.location.reload();
+ this._reloadAfterAction();
} else {
alert('Move failed');
}
@@ -857,7 +871,7 @@ document.addEventListener('alpine:init', function() {
var items = d.items || [];
setTimeout(function() {
self.uploading = false;
- window.location.reload();
+ this._reloadAfterAction();
}, 800);
} else {
this.uploadStatus = '✗ ' + (d.error || 'Upload failed');