Changeset 0.27.1 (#167)

This commit is contained in:
2026-03-10 17:43:29 +00:00
parent 7e4f1581f2
commit 41be9d6081
16 changed files with 780 additions and 57 deletions

View File

@@ -440,6 +440,48 @@ function _resetPaneSize(el) {
// ── Persistence ─────────────────────────────
// v0.27.0: Debounced server sync for cross-device pane layout persistence.
var _paneSyncTimer = null;
function _syncPaneLayoutsToServer() {
if (_paneSyncTimer) clearTimeout(_paneSyncTimer);
_paneSyncTimer = setTimeout(function() {
try {
// Collect all sb_layout_* keys
var layouts = {};
for (var i = 0; i < localStorage.length; i++) {
var k = localStorage.key(i);
if (k && k.indexOf('sb_layout_') === 0) {
try { layouts[k] = JSON.parse(localStorage.getItem(k)); } catch (_) {}
}
}
if (typeof API !== 'undefined' && API._put) {
API._put('/api/v1/settings', { pane_layouts: layouts }).catch(function() {});
}
} catch (_) {}
}, 2000); // 2s debounce — avoid hammering during resize drags
}
// v0.27.0: On page load, restore pane layouts from server if available.
// Called once from PaneContainer init (or surface boot).
function _loadPaneLayoutsFromServer() {
if (typeof API === 'undefined' || !API._get) return;
API._get('/api/v1/settings').then(function(settings) {
if (!settings || !settings.pane_layouts) return;
var layouts = settings.pane_layouts;
for (var key in layouts) {
if (key.indexOf('sb_layout_') === 0 && layouts[key]) {
// Only overwrite if localStorage is empty for this key
if (!localStorage.getItem(key)) {
localStorage.setItem(key, JSON.stringify(layouts[key]));
}
}
}
}).catch(function() {});
}
// Kick off server layout load on script execution
if (typeof API !== 'undefined') _loadPaneLayoutsFromServer();
function _persistSizes(surfaceId, splitEl) {
const key = 'sb_layout_' + surfaceId;
try {
@@ -456,6 +498,9 @@ function _persistSizes(surfaceId, splitEl) {
try { existing = JSON.parse(localStorage.getItem(key) || '{}'); } catch (_) {}
Object.assign(existing, sizes);
localStorage.setItem(key, JSON.stringify(existing));
// v0.27.0: Debounced sync to server for cross-device persistence
_syncPaneLayoutsToServer();
} catch (_) {}
}