Compare commits
No commits in common. "f3308f463fd8bd99a3078b01d50372574e501892" and "42e5deb13314bbd4386b4f78d64b5add7db4d68b" have entirely different histories.
f3308f463f
...
42e5deb133
4 changed files with 19 additions and 79 deletions
|
|
@ -47,10 +47,6 @@ export default {
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
local: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
parentPath: {
|
||||
type: [String, Array],
|
||||
},
|
||||
|
|
@ -263,17 +259,11 @@ export default {
|
|||
const writePath = `simple.${readPath}`
|
||||
|
||||
if (!this.timedApplyMode) {
|
||||
if (this.local) {
|
||||
useLocalConfigStore().set({
|
||||
path: writePath,
|
||||
value,
|
||||
})
|
||||
} else {
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: writePath,
|
||||
value,
|
||||
})
|
||||
}
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: writePath,
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
} else {
|
||||
if (useInterfaceStore().temporaryChangesTimeoutId !== null) {
|
||||
console.error("Can't track more than one temporary change")
|
||||
|
|
@ -282,30 +272,18 @@ export default {
|
|||
|
||||
const oldValue = get(this.configSource, readPath)
|
||||
|
||||
if (this.local) {
|
||||
useLocalConfigStore().setTemporarily({ path: writePath, value })
|
||||
} else {
|
||||
useSyncConfigStore().setPreference({ path: writePath, value })
|
||||
}
|
||||
useSyncConfigStore().setPreference({ path: writePath, value })
|
||||
|
||||
const confirm = () => {
|
||||
if (this.local) {
|
||||
useLocalConfigStore().set({ path: writePath, value })
|
||||
} else {
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
}
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
useInterfaceStore().clearTemporaryChanges()
|
||||
}
|
||||
|
||||
const revert = () => {
|
||||
if (this.local) {
|
||||
useLocalConfigStore().unsetTemporarily({ path: writePath, value })
|
||||
} else {
|
||||
useSyncConfigStore().setPreference({
|
||||
path: writePath,
|
||||
value: oldValue,
|
||||
})
|
||||
}
|
||||
useSyncConfigStore().setPreference({
|
||||
path: writePath,
|
||||
value: oldValue,
|
||||
})
|
||||
useInterfaceStore().clearTemporaryChanges()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@
|
|||
:is-local="status.is_local"
|
||||
@parse-ready="onParseReady"
|
||||
/>
|
||||
{{ mergedConfig }}
|
||||
<div
|
||||
v-show="shouldShowToggle"
|
||||
:class="toggleButtonClasses"
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@ export const defaultState = {
|
|||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
},
|
||||
tempStorage: {
|
||||
...configDefaultState
|
||||
}
|
||||
}
|
||||
|
||||
export const useLocalConfigStore = defineStore('local_config', {
|
||||
|
|
@ -23,12 +20,6 @@ export const useLocalConfigStore = defineStore('local_config', {
|
|||
set({ path, value }) {
|
||||
set(this.prefsStorage, path, value)
|
||||
},
|
||||
setTemporarily({ path, value }) {
|
||||
set(this.tempStorage, path, value)
|
||||
},
|
||||
unsetTemporarily({ path, value }) {
|
||||
set(this.tempStorage, path, undefined)
|
||||
},
|
||||
unset({ path, value }) {
|
||||
set(this.prefsStorage, path, undefined)
|
||||
},
|
||||
|
|
@ -45,7 +36,7 @@ export const useLocalConfigStore = defineStore('local_config', {
|
|||
const result = Object.fromEntries(
|
||||
Object.entries(state.prefsStorage).map(([k, v]) => [
|
||||
k,
|
||||
state.tempStorage[k] ?? v ?? instancePrefs[k],
|
||||
v ?? instancePrefs[k],
|
||||
]),
|
||||
)
|
||||
return result
|
||||
|
|
@ -53,10 +44,7 @@ export const useLocalConfigStore = defineStore('local_config', {
|
|||
},
|
||||
persist: {
|
||||
afterLoad(state) {
|
||||
return {
|
||||
prefStorage: state.prefsStorage,
|
||||
tempStorage: { ...configDefaultState },
|
||||
}
|
||||
return state
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, bas
|
|||
|
||||
export const COMMAND_TRIM_FLAGS = 1000
|
||||
export const COMMAND_TRIM_FLAGS_AND_RESET = 1001
|
||||
export const COMMAND_WIPE_JOURNAL = 1010
|
||||
export const COMMAND_WIPE_JOURNAL_AND_STORAGE = 1011
|
||||
|
||||
export const defaultState = {
|
||||
// do we need to update data on server?
|
||||
|
|
@ -36,7 +34,7 @@ export const defaultState = {
|
|||
flagStorage: {
|
||||
updateCounter: 0, // Counter for most recent update notification seen
|
||||
configMigration: 0, // Counter for config -> server-side migrations
|
||||
reset: 0, // special flag that can be used to force-reset all data, debug purposes only
|
||||
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
|
||||
// 1001: same as above + reset everything to 0
|
||||
|
|
@ -381,30 +379,16 @@ export const _resetFlags = (
|
|||
result[flag] = 0
|
||||
})
|
||||
}
|
||||
} else if (totalFlags.reset > 0 && totalFlags.reset < 9000) {
|
||||
console.debug('Received command to reset the flags')
|
||||
allFlagKeys.forEach((flag) => {
|
||||
result[flag] = 0
|
||||
})
|
||||
}
|
||||
result.reset = 0
|
||||
return result
|
||||
}
|
||||
|
||||
export const _resetPrefs = (
|
||||
totalFlags,
|
||||
totalPrefs,
|
||||
knownKeys = defaultState.flagStorage,
|
||||
) => {
|
||||
// prefs reset functionality
|
||||
if (
|
||||
totalFlags.reset >= COMMAND_WIPE_JOURNAL &&
|
||||
totalFlags.reset <= COMMAND_WIPE_JOURNAL_AND_STORAGE
|
||||
) {
|
||||
console.debug('Received command to reset journals')
|
||||
clearJournals()
|
||||
if (totalFlags.reset === COMMAND_WIPE_JOURNAL_AND_STORAGE) {
|
||||
console.debug('Received command to reset storage')
|
||||
return cloneDeep(defaultState)
|
||||
}
|
||||
} return totalPrefs
|
||||
}
|
||||
|
||||
export const _doMigrations = (cache, live) => {
|
||||
const data = cache ?? live
|
||||
|
||||
|
|
@ -594,14 +578,6 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
Object.keys(this).forEach((k) => {
|
||||
this[k] = blankState[k]
|
||||
})
|
||||
this.flagStorage.reset = COMMAND_WIPE_JOURNAL_AND_STORAGE
|
||||
},
|
||||
clearJournals() {
|
||||
this.flagStorage.reset = COMMAND_WIPE_JOURNAL
|
||||
this.prefsStorage._journal = []
|
||||
this.cache.prefsStorage._journal = []
|
||||
this.raw.prefsStorage._journal = []
|
||||
this.pushSyncConfig()
|
||||
},
|
||||
setSyncConfig(userData) {
|
||||
const live = userData.storage
|
||||
|
|
@ -657,7 +633,6 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
totalPrefs = recent.prefsStorage
|
||||
}
|
||||
|
||||
totalPrefs = _resetPrefs(totalPrefs, totalFlags)
|
||||
totalFlags = _resetFlags(totalFlags)
|
||||
|
||||
recent.flagStorage = { ...flagsTemplate, ...totalFlags }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue