From c1ca0aaecd66917ed046bf8307d3c3472247d7c9 Mon Sep 17 00:00:00 2001 From: bordun Date: Tue, 24 Mar 2020 11:47:10 +0100 Subject: [PATCH] state: store quickstate in client localStorage --- CHANGELOG.md | 4 ++++ src/client/managers/state.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b64cf30..971809bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,6 +94,10 @@ - added `storage` object, proxy to the document's sessionStorage object (allows storing data that persist after page refresh, but not closing) - added `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` function proxies with an extra `id` argument (they clear automatically when called multiple times and upon widget removal. `id` is scoped to the widget) + +- state + - quickstate (store/recall from menu) is now stored in the clients cache and persists after refresh/close (cleared with the browser's cache) + - custom module - `settings.read(name)`: `name` is now the long name of command-line options (not a camelCased one) diff --git a/src/client/managers/state.js b/src/client/managers/state.js index 0e8708eb..d465db22 100644 --- a/src/client/managers/state.js +++ b/src/client/managers/state.js @@ -15,7 +15,7 @@ var StateManager = class StateManager { this.statePath = '' this.lastDir = null - this.quickState = null + this.quickState = JSON.parse(localStorage.getItem('osc.state.quickState')) || null this.valueStateQueue = {} this.valueOldPropQueue = {} @@ -182,6 +182,7 @@ var StateManager = class StateManager { quickSave() { this.quickState = deepCopy(this.get()) + localStorage.setItem('osc.state.quickState', JSON.stringify(this.quickState)) }