aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/update_notification/update_notification.js4
-rw-r--r--src/modules/serverSideStorage.js23
2 files changed, 20 insertions, 7 deletions
diff --git a/src/components/update_notification/update_notification.js b/src/components/update_notification/update_notification.js
index ba008d81..609842c4 100644
--- a/src/components/update_notification/update_notification.js
+++ b/src/components/update_notification/update_notification.js
@@ -38,7 +38,7 @@ const UpdateNotification = {
return !this.$store.state.instance.disableUpdateNotification &&
this.$store.state.users.currentUser &&
this.$store.state.serverSideStorage.flagStorage.updateCounter < CURRENT_UPDATE_COUNTER &&
- !this.$store.state.serverSideStorage.flagStorage.dontShowUpdateNotifs
+ !this.$store.state.serverSideStorage.prefsStorage.simple.dontShowUpdateNotifs
}
},
methods: {
@@ -48,7 +48,7 @@ const UpdateNotification = {
neverShowAgain () {
this.toggleShow()
this.$store.commit('setFlag', { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER })
- this.$store.commit('setFlag', { flag: 'dontShowUpdateNotifs', value: 1 })
+ this.$store.commit('setPreference', { path: 'simple.dontShowUpdateNotifs', value: true })
this.$store.dispatch('pushServerSideStorage')
},
dismiss () {
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