diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-10 02:31:41 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-10 02:37:09 +0300 |
| commit | 2c0eb29b286edf57d75c6044855ea5be9187493b (patch) | |
| tree | b628aa739d4f52249743f25135c7a3fc5c8d9b2e /src/modules | |
| parent | aa41cedd932e88b030ecc3cc54848b5aa300eec3 (diff) | |
more prefs storage work + move dontShowUpdateNotifs to prefs
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/serverSideStorage.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/modules/serverSideStorage.js b/src/modules/serverSideStorage.js index 08ba48bb..bb647b97 100644 --- a/src/modules/serverSideStorage.js +++ b/src/modules/serverSideStorage.js @@ -14,9 +14,6 @@ export const defaultState = { // storage of flags - stuff that can only be set and incremented flagStorage: { updateCounter: 0, // Counter for most recent update notification seen - // TODO move to prefsStorage when that becomes a thing since only way - // this can be reset is by complete reset of all flags - dontShowUpdateNotifs: 0, // if user chose to not show update notifications ever again reset: 0 // special flag that can be used to force-reset all flags, debug purposes only // special reset codes: // 1000: trim keys to those known by currently running FE @@ -24,7 +21,9 @@ export const defaultState = { }, prefsStorage: { _journal: [], - simple: {} + simple: { + dontShowUpdateNotifs: false + } }, // raw data raw: null, @@ -248,6 +247,20 @@ export const mutations = { setFlag (state, { flag, value }) { state.flagStorage[flag] = value state.dirty = true + }, + setPreference (state, { path, value }) { + if (path.startsWith('_')) { + console.error(`tried to edit internal (starts with _) field '${path}', ignoring.`) + return + } + set(state.prefsStorage, path, value) + state.prefsStorage._journal = uniqBy( + [ + ...state.prefsStorage._journal, + { command: 'set', path, args: [value], timestamp: Date.now() } + ].sort((a, b) => a.timestamp > b.timestamp ? -1 : 1), + 'path' + ).reverse() } } @@ -262,7 +275,7 @@ const serverSideStorage = { if (!needPush) return state.cache = _wrapData({ flagStorage: toRaw(state.flagStorage), - prefsStorage: toRaw(state.flagStorage) + prefsStorage: toRaw(state.prefsStorage) }) const params = { pleroma_settings_store: { 'pleroma-fe': state.cache } } rootState.api.backendInteractor |
