This commit is contained in:
Henry Jameson 2026-02-16 16:58:11 +02:00
commit 2e53707324
20 changed files with 115 additions and 99 deletions

View file

@ -74,7 +74,7 @@ export default {
created() {
// Load the locale from the storage
const val = useSyncConfigStore().mergedConfig.interfaceLanguage
useSyncConfigStore().setPreference({ path: 'simple.interfaceLanguage', value: val })
useSyncConfigStore().setSimplePrefAndSave({ path: 'interfaceLanguage', value: val })
document.getElementById('modal').classList = ['-' + this.layoutType]
// Create bound handlers

View file

@ -61,8 +61,8 @@ const ExtraNotifications = {
return useInterfaceStore().openSettingsModalTab('notifications')
},
dismissConfigurationTip() {
return useSyncConfigStore().setPreference({
path: 'simple.showExtraNotificationsTip',
return useSyncConfigStore().setSimplePrefAndSave({
path: 'showExtraNotificationsTip',
value: false,
})
},

View file

@ -84,8 +84,8 @@ const NavPanel = {
this.editMode = !this.editMode
},
toggleCollapse() {
useSyncConfigStore().setPreference({
path: 'simple.collapseNav',
useSyncConfigStore().setSimplePrefAndSave({
path: 'collapseNav',
value: !this.collapsed,
})
useSyncConfigStore().pushSyncConfig()

View file

@ -124,8 +124,8 @@ export default {
},
methods: {
toggleNotificationFilter(type) {
useSyncConfigStore().setPreference({
path: 'simple.notificationVisibility',
useSyncConfigStore().setSimplePrefAndSave({
path: 'notificationVisibility',
value: {
...this.filters,
[type]: !this.filters[type],

View file

@ -819,8 +819,8 @@ const PostStatusForm = {
}
},
dismissScopeNotice() {
useSyncConfigStore().setPreference({
path: 'simple.hideScopeNotice',
useSyncConfigStore().setSimplePrefAndSave({
path: 'hideScopeNotice',
value: true,
})
},

View file

@ -20,8 +20,8 @@ const QuickFilterSettings = {
},
methods: {
setReplyVisibility(visibility) {
useSyncConfigStore().setPreference({
path: 'simple.replyVisibility',
useSyncConfigStore().setSimplePrefAndSave({
path: 'replyVisibility',
value: visibility,
})
this.$store.dispatch('queueFlushAll')
@ -87,9 +87,9 @@ const QuickFilterSettings = {
},
set() {
const value = !this.hideMedia
useSyncConfigStore().setPreference({ path: 'simple.hideAttachments', value })
useSyncConfigStore().setPreference({
path: 'simple.hideAttachmentsInConv',
useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value })
useSyncConfigStore().setSimplePrefAndSave({
path: 'hideAttachmentsInConv',
value,
})
},
@ -100,8 +100,8 @@ const QuickFilterSettings = {
},
set() {
const value = !this.hideMutedPosts
useSyncConfigStore().setPreference({
path: 'simple.hideFilteredStatuses',
useSyncConfigStore().setSimplePrefAndSave({
path: 'hideFilteredStatuses',
value,
})
},
@ -112,7 +112,7 @@ const QuickFilterSettings = {
},
set() {
const value = !this.muteBotStatuses
useSyncConfigStore().setPreference({ path: 'simple.muteBotStatuses', value })
useSyncConfigStore().setSimplePrefAndSave({ path: 'muteBotStatuses', value })
},
},
muteSensitiveStatuses: {
@ -121,8 +121,8 @@ const QuickFilterSettings = {
},
set() {
const value = !this.muteSensitiveStatuses
useSyncConfigStore().setPreference({
path: 'simple.muteSensitiveStatuses',
useSyncConfigStore().setSimplePrefAndSave({
path: 'muteSensitiveStatuses',
value,
})
},

View file

@ -42,8 +42,8 @@ const QuickViewSettings = {
return this.mergedConfig.conversationDisplay
},
set(value) {
useSyncConfigStore().setPreference({
path: 'simple.conversationDisplay',
useSyncConfigStore().setSimplePrefAndSave({
path: 'conversationDisplay',
value,
})
},
@ -54,7 +54,7 @@ const QuickViewSettings = {
},
set() {
const value = !this.autoUpdate
useSyncConfigStore().setPreference({ path: 'simple.streaming', value })
useSyncConfigStore().setSimplePrefAndSave({ path: 'streaming', value })
},
},
collapseWithSubjects: {
@ -63,8 +63,8 @@ const QuickViewSettings = {
},
set() {
const value = !this.collapseWithSubjects
useSyncConfigStore().setPreference({
path: 'simple.collapseMessageWithSubject',
useSyncConfigStore().setSimplePrefAndSave({
path: 'collapseMessageWithSubject',
value,
})
},
@ -75,8 +75,8 @@ const QuickViewSettings = {
},
set() {
const value = !this.showUserAvatars
useSyncConfigStore().setPreference({
path: 'simple.mentionLinkShowAvatar',
useSyncConfigStore().setSimplePrefAndSave({
path: 'mentionLinkShowAvatar',
value,
})
},
@ -87,8 +87,8 @@ const QuickViewSettings = {
},
set() {
const value = !this.muteBotStatuses
useSyncConfigStore().setPreference({
path: 'simple.muteBotStatuses',
useSyncConfigStore().setSimplePrefAndSave({
path: 'muteBotStatuses',
value,
})
},
@ -99,8 +99,8 @@ const QuickViewSettings = {
},
set() {
const value = !this.muteSensitiveStatuses
useSyncConfigStore().setPreference({
path: 'simple.muteSensitiveStatuses',
useSyncConfigStore().setSimplePrefAndSave({
path: 'muteSensitiveStatuses',
value,
})
},

View file

@ -259,7 +259,7 @@ export default {
const writePath = `simple.${readPath}`
if (!this.timedApplyMode) {
useSyncConfigStore().setPreference({ path: writePath, value })
useSyncConfigStore().setSimplePrefAndSave({ path: writePath, value })
useSyncConfigStore().pushSyncConfig()
} else {
if (useInterfaceStore().temporaryChangesTimeoutId !== null) {

View file

@ -195,8 +195,8 @@ const SettingsModal = {
return useSyncConfigStore().mergedConfig.expertLevel > 0
},
set(value) {
useSyncConfigStore().setPreference({
path: 'simple.expertLevel',
useSyncConfigStore().setSimplePrefAndSave({
path: 'expertLevel',
value: value ? 1 : 0,
})
},

View file

@ -52,8 +52,8 @@ const ClutterTab = {
if (value !== 'ask' && value !== 'forever') {
realValue = '14d'
}
useSyncConfigStore().setPreference({
path: 'simple.onMuteDefaultAction',
useSyncConfigStore().setSimplePrefAndSave({
path: 'onMuteDefaultAction',
value: realValue,
})
},
@ -72,8 +72,8 @@ const ClutterTab = {
if (value !== 'ask' && value !== 'forever') {
realValue = '14d'
}
useSyncConfigStore().setPreference({
path: 'simple.onBlockDefaultAction',
useSyncConfigStore().setSimplePrefAndSave({
path: 'onBlockDefaultAction',
value: realValue,
})
},
@ -90,8 +90,8 @@ const ClutterTab = {
},
methods: {
...mapActions(useSyncConfigStore, [
'setPreference',
'unsetPreference',
'setSimplePrefAndSave',
'unsetSimplePrefAndSave',
'pushSyncConfig',
]),
getDatetimeLocal(timestamp) {
@ -138,7 +138,7 @@ const ClutterTab = {
filter.order = this.muteFilters.length + 2
this.muteFiltersDraftObject[newId] = filter
this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter })
this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter })
this.pushSyncConfig()
},
exportFilter(id) {
@ -154,18 +154,18 @@ const ClutterTab = {
const newId = uuidv4()
this.muteFiltersDraftObject[newId] = filter
this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter })
this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter })
this.pushSyncConfig()
},
deleteFilter(id) {
delete this.muteFiltersDraftObject[id]
this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null })
this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null })
this.pushSyncConfig()
},
purgeExpiredFilters() {
this.muteFiltersExpired.forEach(([id]) => {
delete this.muteFiltersDraftObject[id]
this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null })
this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null })
})
this.pushSyncConfig()
},
@ -189,8 +189,8 @@ const ClutterTab = {
this.muteFiltersDraftDirty[id] = true
},
saveFilter(id) {
this.setPreference({
path: 'simple.muteFilters.' + id,
this.setSimplePrefAndSave({
path: 'muteFilters.' + id,
value: this.muteFiltersDraftObject[id],
})
this.pushSyncConfig()

View file

@ -120,8 +120,8 @@ const ComposingTab = {
return useSyncConfigStore().mergedConfig.interfaceLanguage
},
set: function (val) {
useSyncConfigStore().setPreference({
path: 'simple.interfaceLanguage',
useSyncConfigStore().setSimplePrefAndSave({
path: 'interfaceLanguage',
value: val,
})
},
@ -172,8 +172,8 @@ const ComposingTab = {
})
},
updateFont(key, value) {
useSyncConfigStore().setPreference({
path: 'simple.theme3hacks',
useSyncConfigStore().setSimplePrefAndSave({
path: 'theme3hacks',
value: {
...this.mergedConfig.theme3hacks,
fonts: {

View file

@ -36,11 +36,11 @@ const FilteringTab = {
label: this.$t(`user_card.mute_block_${mode}`),
})),
muteFiltersDraftObject: cloneDeep(
useSyncConfigStore().prefsStorage.simple.muteFilters,
this.prefsStorage.simple.muteFilters,
),
muteFiltersDraftDirty: Object.fromEntries(
Object.entries(
useSyncConfigStore().prefsStorage.simple.muteFilters,
this.prefsStorage.simple.muteFilters,
).map(([k]) => [k, false]),
),
exportedFilter: null,
@ -112,7 +112,7 @@ const FilteringTab = {
if (value !== 'ask' && value !== 'forever') {
realValue = '14d'
}
useSyncConfigStore().setPreference({
this.setPreference({
path: 'simple.onMuteDefaultAction',
value: realValue,
})
@ -132,7 +132,7 @@ const FilteringTab = {
if (value !== 'ask' && value !== 'forever') {
realValue = '14d'
}
useSyncConfigStore().setPreference({
this.setPreference({
path: 'simple.onBlockDefaultAction',
value: realValue,
})
@ -151,7 +151,9 @@ const FilteringTab = {
methods: {
...mapActions(useSyncConfigStore, [
'setPreference',
'setPrefAndSave',
'unsetPreference',
'unsetPrefAndSave',
'pushSyncConfig',
]),
getDatetimeLocal(timestamp) {
@ -198,8 +200,7 @@ const FilteringTab = {
filter.order = this.muteFilters.length + 2
this.muteFiltersDraftObject[newId] = filter
this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter })
this.pushSyncConfig()
this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter })
},
exportFilter(id) {
this.exportedFilter = { ...this.muteFiltersDraftObject[id] }
@ -214,13 +215,11 @@ const FilteringTab = {
const newId = uuidv4()
this.muteFiltersDraftObject[newId] = filter
this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter })
this.pushSyncConfig()
this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter })
},
deleteFilter(id) {
delete this.muteFiltersDraftObject[id]
this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null })
this.pushSyncConfig()
this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null })
},
purgeExpiredFilters() {
this.muteFiltersExpired.forEach(([id]) => {
@ -249,11 +248,10 @@ const FilteringTab = {
this.muteFiltersDraftDirty[id] = true
},
saveFilter(id) {
this.setPreference({
path: 'simple.muteFilters.' + id,
this.setPrefAndSave({
path: 'muteFilters.' + id,
value: this.muteFiltersDraftObject[id],
})
this.pushSyncConfig()
this.muteFiltersDraftDirty[id] = false
},
},

View file

@ -41,8 +41,8 @@ const GeneralTab = {
return useSyncConfigStore().mergedConfig.interfaceLanguage
},
set: function (val) {
useSyncConfigStore().setPreference({
path: 'simple.interfaceLanguage',
useSyncConfigStore().setSimplePrefAndSave({
path: 'interfaceLanguage',
value: val,
})
},
@ -69,8 +69,8 @@ const GeneralTab = {
})
},
updateFont(key, value) {
useSyncConfigStore().setPreference({
path: 'simple.theme3hacks',
useSyncConfigStore().setSimplePrefAndSave({
path: 'theme3hacks',
value: {
...this.mergedConfig.theme3hacks,
fonts: {

View file

@ -67,8 +67,8 @@ const GeneralTab = {
},
methods: {
updateFont(key, value) {
useSyncConfigStore().setPreference({
path: 'simple.theme3hacks',
useSyncConfigStore().setSimplePrefAndSave({
path: 'theme3hacks',
value: {
...this.mergedConfig.theme3hacks,
fonts: {

View file

@ -57,8 +57,8 @@ const UpdateNotification = {
flag: 'updateCounter',
value: CURRENT_UPDATE_COUNTER,
})
useSyncConfigStore().setPreference({
path: 'simple.dontShowUpdateNotifs',
useSyncConfigStore().setSimplePrefAndSave({
path: 'dontShowUpdateNotifs',
value: true,
})
useSyncConfigStore().pushSyncConfig()

View file

@ -84,16 +84,16 @@ const UserTimedFilterModal = {
if (this.isMute) {
this.$store.dispatch('muteUser', this.requestBody)
if (this.dontAskAgain) {
this.$store.dispatch('setOption', {
name: 'onMuteDefaultAction',
useSyncConfigStore().setSimplePrefAndSave({
path: 'onMuteDefaultAction',
value: this.expiryString,
})
}
} else {
this.$store.dispatch('blockUser', this.requestBody)
if (this.dontAskAgain) {
this.$store.dispatch('setOption', {
name: 'onBlockDefaultAction',
useSyncConfigStore().setSimplePrefAndSave({
path: 'onBlockDefaultAction',
value: this.expiryString,
})
}

View file

@ -10,7 +10,7 @@ const simpleDeclaration = {
store: 'server-side',
migrationFlag: 'configMigration',
migration(serverside, rootState) {
serverside.setPreference({ path: 'simple.' + field, value: rootState.config[oldField ?? field] })
serverside.setSimplePrefAndSave({ path: field, value: rootState.config[oldField ?? field] })
}
}
*/

View file

@ -725,7 +725,7 @@ const users = {
Object.keys(
useSyncConfigStore().prefsStorage.simple.muteFilters
).forEach(key => {
useSyncConfigStore().unsetPreference({ path: 'simple.muteFilters.' + key, value: null })
useSyncConfigStore().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null })
})
// Reset flag to 0 to re-run migrations

View file

@ -226,14 +226,14 @@ export const useInterfaceStore = defineStore('interface', {
try {
const value = await getResourcesIndex('/static/palettes/index.json')
useInstanceStore().set({
name: 'palettesIndex',
path: 'palettesIndex',
value,
})
return value
} catch (e) {
console.error('Could not fetch palettes index', e)
useInstanceStore().set({
name: 'palettesIndex',
path: 'palettesIndex',
value: { _error: e },
})
return Promise.resolve({})
@ -243,7 +243,8 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV3Palette()
this.resetThemeV2()
window.vuex.commit('setOption', { name: 'palette', value })
useSyncConfigStore().setPreference({ path: 'simple.palette', value })
useSyncConfigStore().pushSyncConfig()
this.applyTheme({ recompile: true })
},
@ -251,7 +252,8 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV3Palette()
this.resetThemeV2()
window.vuex.commit('setOption', { name: 'paletteCustomData', value })
useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value })
useSyncConfigStore().pushSyncConfig()
this.applyTheme({ recompile: true })
},
@ -261,12 +263,12 @@ export const useInterfaceStore = defineStore('interface', {
'/static/styles/index.json',
deserialize,
)
useInstanceStore().set({ name: 'stylesIndex', value })
useInstanceStore().set({ path: 'stylesIndex', value })
return value
} catch (e) {
console.error('Could not fetch styles index', e)
useInstanceStore().set({
name: 'stylesIndex',
path: 'simple.stylesIndex',
value: { _error: e },
})
return Promise.resolve({})
@ -277,7 +279,8 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV2()
this.resetThemeV3Palette()
window.vuex.commit('setOption', { name: 'style', value })
useSyncConfigStore().setPreference({ path: 'simple.style', value })
useSyncConfigStore().pushSyncConfig()
this.useStylePalette = true
this.applyTheme({ recompile: true }).then(() => {
@ -289,7 +292,8 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV2()
this.resetThemeV3Palette()
window.vuex.commit('setOption', { name: 'styleCustomData', value })
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value })
useSyncConfigStore().pushSyncConfig()
this.useStylePalette = true
this.applyTheme({ recompile: true }).then(() => {
@ -299,12 +303,12 @@ export const useInterfaceStore = defineStore('interface', {
async fetchThemesIndex() {
try {
const value = await getResourcesIndex('/static/styles.json')
useInstanceStore().set({ name: 'themesIndex', value })
useInstanceStore().set({ path: 'simple.themesIndex', value })
return value
} catch (e) {
console.error('Could not fetch themes index', e)
useInstanceStore().set({
name: 'themesIndex',
path: 'themesIndex',
value: { _error: e },
})
return Promise.resolve({})
@ -315,7 +319,8 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV3Palette()
this.resetThemeV2()
window.vuex.commit('setOption', { name: 'theme', value })
useSyncConfigStore().setPreference({ path: 'simple.theme', value })
useSyncConfigStore().pushSyncConfig()
this.applyTheme({ recompile: true })
},
@ -324,29 +329,33 @@ export const useInterfaceStore = defineStore('interface', {
this.resetThemeV3Palette()
this.resetThemeV2()
window.vuex.commit('setOption', { name: 'customTheme', value })
window.vuex.commit('setOption', { name: 'customThemeSource', value })
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value })
useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value })
useSyncConfigStore().pushSyncConfig()
this.applyTheme({ recompile: true })
},
resetThemeV3() {
window.vuex.commit('setOption', { name: 'style', value: null })
window.vuex.commit('setOption', { name: 'styleCustomData', value: null })
useSyncConfigStore().setPreference({ path: 'simple.style', value: null })
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null })
useSyncConfigStore().pushSyncConfig()
},
resetThemeV3Palette() {
window.vuex.commit('setOption', { name: 'palette', value: null })
window.vuex.commit('setOption', {
name: 'paletteCustomData',
useSyncConfigStore().setPreference({ path: 'simple.palette', value: null })
useSyncConfigStore().setPreference({
path: 'simple.paletteCustomData',
value: null,
})
useSyncConfigStore().pushSyncConfig()
},
resetThemeV2() {
window.vuex.commit('setOption', { name: 'theme', value: null })
window.vuex.commit('setOption', { name: 'customTheme', value: null })
window.vuex.commit('setOption', {
name: 'customThemeSource',
useSyncConfigStore().setPreference({ path: 'simple.theme', value: null })
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null })
useSyncConfigStore().setPreference({
path: 'simple.customThemeSource',
value: null,
})
useSyncConfigStore().pushSyncConfig()
},
async getThemeData() {
const getData = async (resource, index, customData, name) => {
@ -516,6 +525,7 @@ export const useInterfaceStore = defineStore('interface', {
path: 'simple.palette',
value: firstStylePaletteName,
})
useSyncConfigStore().pushSyncConfig()
}
this.paletteNameUsed = palette.nameUsed

View file

@ -417,6 +417,14 @@ export const useSyncConfigStore = defineStore('sync_config', {
this.flagStorage[flag] = value
this.dirty = true
},
setSimplePrefAndSave({ path, value }) {
this.setPreference({ path: `simple.${path}`, value })
this.pushSyncConfig()
},
unsetSimplePrefAndSave({ path }) {
this.unsetPreference({ path: `simple.${path}` })
this.pushSyncConfig()
},
setPreference({ path, value }) {
if (path.startsWith('_')) {
throw new Error(
@ -472,7 +480,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
`Calling unset on depth > 3 (path: ${path}) is not allowed`,
)
}
unset(this.prefsStorage, path, value)
unset(this.prefsStorage, path)
this.prefsStorage._journal = [
...this.prefsStorage._journal,
{ operation: 'unset', path, args: [], timestamp: Date.now() },