Merge branch 'setttingssync' into shigusegubu-themes3
This commit is contained in:
commit
f6fd5ed8c4
16 changed files with 121 additions and 110 deletions
|
|
@ -21,14 +21,7 @@ export default {
|
||||||
Popover,
|
Popover,
|
||||||
LocalSettingIndicator,
|
LocalSettingIndicator,
|
||||||
},
|
},
|
||||||
props: [
|
props: ['name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'],
|
||||||
'name',
|
|
||||||
'label',
|
|
||||||
'modelValue',
|
|
||||||
'fallback',
|
|
||||||
'options',
|
|
||||||
'no-inherit',
|
|
||||||
],
|
|
||||||
mounted() {
|
mounted() {
|
||||||
useInterfaceStore().queryLocalFonts()
|
useInterfaceStore().queryLocalFonts()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||||
import Setting from './setting.js'
|
import Setting from './setting.js'
|
||||||
|
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
...Setting,
|
...Setting,
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -43,7 +45,7 @@ export default {
|
||||||
if (this.forceNew) return true
|
if (this.forceNew) return true
|
||||||
if (!this.allowNew) return false
|
if (!this.allowNew) return false
|
||||||
|
|
||||||
const isExpert = this.$store.state.config.expertLevel > 0
|
const isExpert = useSyncConfigStore().mergedConfig.expertLevel > 0
|
||||||
const hasBuiltins = this.builtinEntries.length > 0
|
const hasBuiltins = this.builtinEntries.length > 0
|
||||||
|
|
||||||
if (hasBuiltins) {
|
if (hasBuiltins) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
|
||||||
import Popover from '../popover/popover.vue'
|
import Popover from '../popover/popover.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import {
|
||||||
|
LOCAL_ONLY_KEYS,
|
||||||
|
useLocalConfigStore,
|
||||||
|
} from 'src/stores/local_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -137,7 +141,34 @@ const SettingsModal = {
|
||||||
},
|
},
|
||||||
onImport(data) {
|
onImport(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
this.$store.dispatch('loadSettings', data)
|
Object.entries(data).forEach(([path, value]) => {
|
||||||
|
if (LOCAL_ONLY_KEYS.has(path)) {
|
||||||
|
useLocalConfigStore().set({ path, value })
|
||||||
|
} else {
|
||||||
|
if (path.startsWith('muteFilters')) {
|
||||||
|
Object.keys(
|
||||||
|
useSyncConfigStore().mergedConfig.muteFilters,
|
||||||
|
).forEach((key) => {
|
||||||
|
useSyncConfigStore().unsetPreference({
|
||||||
|
path: `simple.${path}.${key}`,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Object.entries(value).forEach(([key, filter]) => {
|
||||||
|
useSyncConfigStore().setPreference({
|
||||||
|
path: `simple.${path}.${key}`,
|
||||||
|
value: filter,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
useSyncConfigStore().setPreference({
|
||||||
|
path: `simple.${path}`,
|
||||||
|
value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
useSyncConfigStore().pushSyncConfig()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
restore() {
|
restore() {
|
||||||
|
|
@ -150,7 +181,7 @@ const SettingsModal = {
|
||||||
this.dataThemeExporter.exportData()
|
this.dataThemeExporter.exportData()
|
||||||
},
|
},
|
||||||
generateExport(theme = false) {
|
generateExport(theme = false) {
|
||||||
const { config } = this.$store.state
|
const config = useSyncConfigStore().mergedConfigWithoutDefaults
|
||||||
let sample = config
|
let sample = config
|
||||||
if (!theme) {
|
if (!theme) {
|
||||||
const ignoreList = new Set([
|
const ignoreList = new Set([
|
||||||
|
|
@ -159,7 +190,9 @@ const SettingsModal = {
|
||||||
'colors',
|
'colors',
|
||||||
])
|
])
|
||||||
sample = Object.fromEntries(
|
sample = Object.fromEntries(
|
||||||
Object.entries(sample).filter(([key]) => !ignoreList.has(key)),
|
Object.entries(sample).filter(
|
||||||
|
([key, value]) => !ignoreList.has(key) && value !== undefined,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const clone = cloneDeep(sample)
|
const clone = cloneDeep(sample)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import SecurityTab from './tabs/security_tab/security_tab.vue'
|
||||||
import StyleTab from './tabs/style_tab/style_tab.vue'
|
import StyleTab from './tabs/style_tab/style_tab.vue'
|
||||||
|
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
|
|
@ -83,7 +84,7 @@ const SettingsModalContent = {
|
||||||
return useInterfaceStore().settingsModalState === 'visible'
|
return useInterfaceStore().settingsModalState === 'visible'
|
||||||
},
|
},
|
||||||
expertLevel() {
|
expertLevel() {
|
||||||
return this.$store.state.config.expertLevel
|
return useSyncConfigStore().mergedConfig.expertLevel
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -38,55 +38,6 @@ const ClutterTab = {
|
||||||
Object.entries(store.prefsStorage.simple.muteFilters),
|
Object.entries(store.prefsStorage.simple.muteFilters),
|
||||||
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
||||||
}),
|
}),
|
||||||
onMuteDefaultActionLv1: {
|
|
||||||
get() {
|
|
||||||
const value = this.$store.state.config.onMuteDefaultAction
|
|
||||||
if (value === 'ask' || value === 'forever') {
|
|
||||||
return value
|
|
||||||
} else {
|
|
||||||
return 'temporarily'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
let realValue = value
|
|
||||||
if (value !== 'ask' && value !== 'forever') {
|
|
||||||
realValue = '14d'
|
|
||||||
}
|
|
||||||
useSyncConfigStore().setSimplePrefAndSave({
|
|
||||||
path: 'onMuteDefaultAction',
|
|
||||||
value: realValue,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
onBlockDefaultActionLv1: {
|
|
||||||
get() {
|
|
||||||
const value = this.$store.state.config.onBlockDefaultAction
|
|
||||||
if (value === 'ask' || value === 'forever') {
|
|
||||||
return value
|
|
||||||
} else {
|
|
||||||
return 'temporarily'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
let realValue = value
|
|
||||||
if (value !== 'ask' && value !== 'forever') {
|
|
||||||
realValue = '14d'
|
|
||||||
}
|
|
||||||
useSyncConfigStore().setSimplePrefAndSave({
|
|
||||||
path: 'onBlockDefaultAction',
|
|
||||||
value: realValue,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
muteFiltersDraft() {
|
|
||||||
return Object.entries(this.muteFiltersDraftObject)
|
|
||||||
},
|
|
||||||
muteFiltersExpired() {
|
|
||||||
const now = Date.now()
|
|
||||||
return Object.entries(this.muteFiltersDraftObject).filter(
|
|
||||||
([, { expires }]) => expires != null && expires <= now,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useSyncConfigStore, [
|
...mapActions(useSyncConfigStore, [
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,7 @@
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="shoutAvailable">
|
<li v-if="shoutAvailable">
|
||||||
<BooleanSetting
|
<BooleanSetting path="hideShoutbox">
|
||||||
path="hideShoutbox"
|
|
||||||
>
|
|
||||||
{{ $t('settings.hide_shoutbox') }}
|
{{ $t('settings.hide_shoutbox') }}
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -93,14 +93,12 @@ const FilteringTab = {
|
||||||
computed: {
|
computed: {
|
||||||
...SharedComputedObject(),
|
...SharedComputedObject(),
|
||||||
...mapState(useSyncConfigStore, {
|
...mapState(useSyncConfigStore, {
|
||||||
muteFilters: (store) =>
|
|
||||||
Object.entries(store.prefsStorage.simple.muteFilters),
|
|
||||||
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
||||||
}),
|
}),
|
||||||
...mapState(useInstanceCapabilitiesStore, ['blockExpiration']),
|
...mapState(useInstanceCapabilitiesStore, ['blockExpiration']),
|
||||||
onMuteDefaultActionLv1: {
|
onMuteDefaultActionLv1: {
|
||||||
get() {
|
get() {
|
||||||
const value = this.$store.state.config.onMuteDefaultAction
|
const value = useSyncConfigStore().mergedConfig.onMuteDefaultAction
|
||||||
if (value === 'ask' || value === 'forever') {
|
if (value === 'ask' || value === 'forever') {
|
||||||
return value
|
return value
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -120,7 +118,7 @@ const FilteringTab = {
|
||||||
},
|
},
|
||||||
onBlockDefaultActionLv1: {
|
onBlockDefaultActionLv1: {
|
||||||
get() {
|
get() {
|
||||||
const value = this.$store.state.config.onBlockDefaultAction
|
const value = useSyncConfigStore().mergedConfig.onBlockDefaultAction
|
||||||
if (value === 'ask' || value === 'forever') {
|
if (value === 'ask' || value === 'forever') {
|
||||||
return value
|
return value
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -151,7 +149,7 @@ const FilteringTab = {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useSyncConfigStore, [
|
...mapActions(useSyncConfigStore, [
|
||||||
'setPreference',
|
'setPreference',
|
||||||
'setPrefAndSave',
|
'setSimplePrefAndSave',
|
||||||
'unsetPreference',
|
'unsetPreference',
|
||||||
'unsetPrefAndSave',
|
'unsetPrefAndSave',
|
||||||
'pushSyncConfig',
|
'pushSyncConfig',
|
||||||
|
|
@ -260,6 +258,12 @@ const FilteringTab = {
|
||||||
replyVisibility() {
|
replyVisibility() {
|
||||||
this.$store.dispatch('queueFlushAll')
|
this.$store.dispatch('queueFlushAll')
|
||||||
},
|
},
|
||||||
|
muteFiltersObject() {
|
||||||
|
console.log('UPDATE')
|
||||||
|
this.muteFiltersDraftObject = cloneDeep(
|
||||||
|
useSyncConfigStore().prefsStorage.simple.muteFilters,
|
||||||
|
)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@
|
||||||
<ChoiceSetting
|
<ChoiceSetting
|
||||||
id="mentionLinkDisplay"
|
id="mentionLinkDisplay"
|
||||||
path="mentionLinkDisplay"
|
path="mentionLinkDisplay"
|
||||||
|
:local="true"
|
||||||
:options="mentionLinkDisplayOptions"
|
:options="mentionLinkDisplayOptions"
|
||||||
>
|
>
|
||||||
{{ $t('settings.mention_link_display') }}
|
{{ $t('settings.mention_link_display') }}
|
||||||
|
|
@ -171,7 +172,10 @@
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting path="hideNsfw">
|
<BooleanSetting
|
||||||
|
:local="true"
|
||||||
|
path="hideNsfw"
|
||||||
|
>
|
||||||
{{ $t('settings.nsfw_clickthrough') }}
|
{{ $t('settings.nsfw_clickthrough') }}
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
<ul class="setting-list suboptions">
|
<ul class="setting-list suboptions">
|
||||||
|
|
@ -179,6 +183,7 @@
|
||||||
<BooleanSetting
|
<BooleanSetting
|
||||||
path="preloadImage"
|
path="preloadImage"
|
||||||
expert="1"
|
expert="1"
|
||||||
|
:local="true"
|
||||||
parent-path="hideNsfw"
|
parent-path="hideNsfw"
|
||||||
>
|
>
|
||||||
{{ $t('settings.preload_images') }}
|
{{ $t('settings.preload_images') }}
|
||||||
|
|
@ -188,6 +193,7 @@
|
||||||
<BooleanSetting
|
<BooleanSetting
|
||||||
path="useOneClickNsfw"
|
path="useOneClickNsfw"
|
||||||
expert="1"
|
expert="1"
|
||||||
|
:local="true"
|
||||||
parent-path="hideNsfw"
|
parent-path="hideNsfw"
|
||||||
>
|
>
|
||||||
{{ $t('settings.use_one_click_nsfw') }}
|
{{ $t('settings.use_one_click_nsfw') }}
|
||||||
|
|
|
||||||
|
|
@ -381,6 +381,7 @@
|
||||||
"select_all": "Select all"
|
"select_all": "Select all"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
"invalid_settings_imported": "Error importing settings",
|
||||||
"add_language": "Add fallback language",
|
"add_language": "Add fallback language",
|
||||||
"remove_language": "Remove",
|
"remove_language": "Remove",
|
||||||
"primary_language": "Primary language:",
|
"primary_language": "Primary language:",
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ const i18n = createI18n({
|
||||||
messages.setLanguage(i18n.global, currentLocale)
|
messages.setLanguage(i18n.global, currentLocale)
|
||||||
|
|
||||||
const persistedStateOptions = {
|
const persistedStateOptions = {
|
||||||
paths: ['syncConfig.cache', 'config', 'users.lastLoginName', 'oauth'],
|
paths: ['users.lastLoginName', 'oauth'],
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ export const instanceDefaultConfig = {
|
||||||
hideScrobbles: false,
|
hideScrobbles: false,
|
||||||
hideScrobblesAfter: '2d',
|
hideScrobblesAfter: '2d',
|
||||||
maxThumbnails: 16,
|
maxThumbnails: 16,
|
||||||
hideNsfw: true,
|
|
||||||
preloadImage: true,
|
|
||||||
loopVideo: true,
|
loopVideo: true,
|
||||||
loopVideoSilentOnly: true,
|
loopVideoSilentOnly: true,
|
||||||
/// This is not the streaming API configuration, but rather an option
|
/// This is not the streaming API configuration, but rather an option
|
||||||
|
|
@ -121,7 +119,6 @@ export const instanceDefaultConfig = {
|
||||||
|
|
||||||
modalMobileCenter: false,
|
modalMobileCenter: false,
|
||||||
playVideosInModal: false,
|
playVideosInModal: false,
|
||||||
useOneClickNsfw: false,
|
|
||||||
useContainFit: true,
|
useContainFit: true,
|
||||||
disableStickyHeaders: false,
|
disableStickyHeaders: false,
|
||||||
showScrollbars: false,
|
showScrollbars: false,
|
||||||
|
|
@ -165,6 +162,9 @@ export const instanceDefaultConfig = {
|
||||||
export const defaultConfigLocal = {
|
export const defaultConfigLocal = {
|
||||||
hideAttachments: false,
|
hideAttachments: false,
|
||||||
hideAttachmentsInConv: false,
|
hideAttachmentsInConv: false,
|
||||||
|
hideNsfw: true,
|
||||||
|
useOneClickNsfw: false,
|
||||||
|
preloadImage: true,
|
||||||
postContentType: 'text/plain',
|
postContentType: 'text/plain',
|
||||||
sidebarRight: false,
|
sidebarRight: false,
|
||||||
sidebarColumnWidth: '25rem',
|
sidebarColumnWidth: '25rem',
|
||||||
|
|
@ -191,9 +191,12 @@ export const makeUndefined = (c) =>
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
// Set these to undefined so it does not interfere with default settings check
|
// Set these to undefined so it does not interfere with default settings check
|
||||||
...makeUndefined(instanceDefaultConfig),
|
...makeUndefined(instanceDefaultConfig),
|
||||||
|
...makeUndefined(defaultConfigLocal),
|
||||||
|
// If there are any configurations that does not make sense to
|
||||||
|
// have instance-wide default, put it here and explain why.
|
||||||
|
|
||||||
// Special processing
|
// # Special processing
|
||||||
// Theme stuff
|
// ## Theme stuff
|
||||||
theme: undefined, // Very old theme store, stores preset name, still in use
|
theme: undefined, // Very old theme store, stores preset name, still in use
|
||||||
|
|
||||||
// V1
|
// V1
|
||||||
|
|
@ -220,15 +223,4 @@ export const defaultState = {
|
||||||
monospace: undefined,
|
monospace: undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Special handling: These fields are not of a primitive type, and
|
|
||||||
// might cause problems with current code because it specifically checks
|
|
||||||
// them in state.config (not getters.mergedConfig).
|
|
||||||
|
|
||||||
// Specifically, muteWords is now deprecated in favour of a server-side configuration.
|
|
||||||
muteWords: [],
|
|
||||||
highlight: {},
|
|
||||||
|
|
||||||
// If there are any configurations that does not make sense to
|
|
||||||
// have instance-wide default, put it here and explain why.
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@ export const defaultConfigSync = {
|
||||||
hideScrobbles: false,
|
hideScrobbles: false,
|
||||||
hideScrobblesAfter: '2d',
|
hideScrobblesAfter: '2d',
|
||||||
maxThumbnails: 16,
|
maxThumbnails: 16,
|
||||||
hideNsfw: true,
|
|
||||||
preloadImage: true,
|
|
||||||
loopVideo: true,
|
loopVideo: true,
|
||||||
loopVideoSilentOnly: true,
|
loopVideoSilentOnly: true,
|
||||||
/// This is not the streaming API configuration, but rather an option
|
/// This is not the streaming API configuration, but rather an option
|
||||||
|
|
@ -93,7 +91,6 @@ export const defaultConfigSync = {
|
||||||
|
|
||||||
modalMobileCenter: false,
|
modalMobileCenter: false,
|
||||||
playVideosInModal: false,
|
playVideosInModal: false,
|
||||||
useOneClickNsfw: false,
|
|
||||||
useContainFit: true,
|
useContainFit: true,
|
||||||
disableStickyHeaders: false,
|
disableStickyHeaders: false,
|
||||||
showScrollbars: false,
|
showScrollbars: false,
|
||||||
|
|
@ -169,6 +166,9 @@ export const defaultConfigSync = {
|
||||||
export const defaultConfigLocal = {
|
export const defaultConfigLocal = {
|
||||||
hideAttachments: false,
|
hideAttachments: false,
|
||||||
hideAttachmentsInConv: false,
|
hideAttachmentsInConv: false,
|
||||||
|
hideNsfw: true,
|
||||||
|
useOneClickNsfw: false,
|
||||||
|
preloadImage: true,
|
||||||
sidebarColumnWidth: '25rem',
|
sidebarColumnWidth: '25rem',
|
||||||
contentColumnWidth: '45rem',
|
contentColumnWidth: '45rem',
|
||||||
notifsColumnWidth: '25rem',
|
notifsColumnWidth: '25rem',
|
||||||
|
|
@ -182,6 +182,4 @@ export const defaultConfigLocal = {
|
||||||
mentionLinkDisplay: 'short',
|
mentionLinkDisplay: 'short',
|
||||||
imageCompression: true,
|
imageCompression: true,
|
||||||
alwaysUseJpeg: false,
|
alwaysUseJpeg: false,
|
||||||
imageCompression: true,
|
|
||||||
alwaysUseJpeg: false,
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import { useInstanceStore } from 'src/stores/instance'
|
||||||
|
|
||||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||||
|
|
||||||
|
export const LOCAL_ONLY_KEYS = new Set(Object.keys(configDefaultState))
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
prefsStorage: {
|
prefsStorage: {
|
||||||
...configDefaultState,
|
...configDefaultState,
|
||||||
|
|
@ -32,7 +34,7 @@ export const useLocalConfigStore = defineStore('local_config', {
|
||||||
unset({ path, value }) {
|
unset({ path, value }) {
|
||||||
set(this.prefsStorage, path, undefined)
|
set(this.prefsStorage, path, undefined)
|
||||||
},
|
},
|
||||||
clearSyncConfig() {
|
clearLocalConfig() {
|
||||||
const blankState = { ...cloneDeep(defaultState) }
|
const blankState = { ...cloneDeep(defaultState) }
|
||||||
Object.keys(this).forEach((k) => {
|
Object.keys(this).forEach((k) => {
|
||||||
this.prefsStorage[k] = blankState[k]
|
this.prefsStorage[k] = blankState[k]
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,21 @@ import { toRaw } from 'vue'
|
||||||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||||
|
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
import {
|
||||||
|
LOCAL_ONLY_KEYS,
|
||||||
|
useLocalConfigStore,
|
||||||
|
} from 'src/stores/local_config.js'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state.js'
|
import {
|
||||||
|
defaultState as configDefaultState,
|
||||||
|
defaultConfigLocal,
|
||||||
|
instanceDefaultConfig,
|
||||||
|
} from 'src/modules/default_config_state.js'
|
||||||
import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
|
import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||||
|
|
||||||
export const VERSION = 2
|
export const VERSION = 2
|
||||||
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
||||||
|
|
||||||
export const COMMAND_TRIM_FLAGS = 1000
|
export const COMMAND_TRIM_FLAGS = 1000
|
||||||
export const COMMAND_TRIM_FLAGS_AND_RESET = 1001
|
export const COMMAND_TRIM_FLAGS_AND_RESET = 1001
|
||||||
|
|
@ -49,6 +56,7 @@ export const defaultState = {
|
||||||
dontShowUpdateNotifs: false,
|
dontShowUpdateNotifs: false,
|
||||||
collapseNav: false,
|
collapseNav: false,
|
||||||
muteFilters: {},
|
muteFilters: {},
|
||||||
|
|
||||||
...configDefaultState,
|
...configDefaultState,
|
||||||
},
|
},
|
||||||
collections: {
|
collections: {
|
||||||
|
|
@ -615,14 +623,14 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
let dirty = false
|
let dirty = false
|
||||||
|
|
||||||
console.debug('Migrating from old config')
|
console.debug('Migrating from old config')
|
||||||
const vuexState = await storage.getItem('vuex-lz')
|
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||||
const { config } = vuexState
|
vuexState.config = vuexState.config ?? {}
|
||||||
|
|
||||||
const migratedEntries = new Set(config._syncMigration ?? [])
|
const migratedEntries = new Set(vuexState.config._syncMigration ?? [])
|
||||||
console.debug(`Already migrated Values: ${[...migratedEntries].join()}`)
|
console.debug(`Already migrated Values: ${[...migratedEntries].join()}`)
|
||||||
|
|
||||||
Object.entries(defaultConfigSync).forEach(([key, value]) => {
|
Object.entries(defaultConfigSync).forEach(([key, value]) => {
|
||||||
const oldValue = config[key]
|
const oldValue = vuexState.config[key]
|
||||||
const defaultValue = value
|
const defaultValue = value
|
||||||
|
|
||||||
const present = oldValue !== undefined
|
const present = oldValue !== undefined
|
||||||
|
|
@ -630,12 +638,13 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
const different = !isEqual(oldValue, defaultValue)
|
const different = !isEqual(oldValue, defaultValue)
|
||||||
|
|
||||||
if (present && !migrated && different) {
|
if (present && !migrated && different) {
|
||||||
console.debug(`Migrating config ${key}: ${oldValue}`,)
|
console.debug(`Migrating config ${key}: ${oldValue}`)
|
||||||
this.setPreference({ path: `simple.${key}`, oldValue })
|
this.setPreference({ path: `simple.${key}`, oldValue })
|
||||||
migratedEntries.add(key)
|
migratedEntries.add(key)
|
||||||
needUpload = true
|
needUpload = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
vuexState.config._syncMigration = [...migratedEntries]
|
vuexState.config._syncMigration = [...migratedEntries]
|
||||||
storage.setItem('vuex-lz', vuexState)
|
storage.setItem('vuex-lz', vuexState)
|
||||||
|
|
||||||
|
|
@ -716,9 +725,28 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
const localPrefs = useLocalConfigStore().prefsStorage
|
const localPrefs = useLocalConfigStore().prefsStorage
|
||||||
const tempPrefs = useLocalConfigStore().tempStorage
|
const tempPrefs = useLocalConfigStore().tempStorage
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
Object.entries(state.prefsStorage.simple).map(([k, v]) => [
|
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
||||||
k,
|
k,
|
||||||
tempPrefs[k] ?? localPrefs[k] ?? v ?? instancePrefs[k],
|
LOCAL_ONLY_KEYS.has(k)
|
||||||
|
? (tempPrefs[k] ??
|
||||||
|
localPrefs[k] ??
|
||||||
|
instancePrefs[k] ??
|
||||||
|
defaultConfigLocal[k])
|
||||||
|
: (tempPrefs[k] ??
|
||||||
|
localPrefs[k] ??
|
||||||
|
value ??
|
||||||
|
instancePrefs[k] ??
|
||||||
|
instanceDefaultConfig[k]),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
mergedConfigWithoutDefaults: (state) => {
|
||||||
|
const localPrefs = useLocalConfigStore().prefsStorage
|
||||||
|
const result = Object.fromEntries(
|
||||||
|
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
||||||
|
k,
|
||||||
|
LOCAL_ONLY_KEYS.has(k) ? localPrefs[k] : value,
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -278,8 +278,10 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
const userNew = userData.created_at > NEW_USER_DATE
|
const userNew = userData.created_at > NEW_USER_DATE
|
||||||
let dirty = false
|
let dirty = false
|
||||||
|
|
||||||
const vuexState = await storage.getItem('vuex-lz')
|
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||||
const { highlight } = vuexState.config
|
vuexState.config = vuexState.config ?? {}
|
||||||
|
const highlight = vuexState.config.highlight ?? {}
|
||||||
|
|
||||||
Object.entries(highlight).forEach(([user, value]) => {
|
Object.entries(highlight).forEach(([user, value]) => {
|
||||||
if ((highlight[user]._migrated || 0) < 1) {
|
if ((highlight[user]._migrated || 0) < 1) {
|
||||||
dirty = true
|
dirty = true
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ function getWindowClients() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const setSettings = async () => {
|
const setSettings = async () => {
|
||||||
const vuexState = await storage.getItem('vuex-lz')
|
const piniaState = await storage.getItem('pinia-local-sync_config')
|
||||||
const locale = vuexState.config.interfaceLanguage || 'en'
|
const locale = piniaState.prefsStorage.simple.interfaceLanguage || 'en'
|
||||||
i18n.locale = locale
|
i18n.locale = locale
|
||||||
const notificationsNativeArray = Object.entries(
|
const notificationsNativeArray = Object.entries(
|
||||||
vuexState.config.notificationNative,
|
piniaState.prefsStorage.simple.notificationNative,
|
||||||
)
|
)
|
||||||
state.webPushAlwaysShowNotifications =
|
state.webPushAlwaysShowNotifications =
|
||||||
vuexState.config.webPushAlwaysShowNotifications
|
piniaState.prefsStorage.simple.webPushAlwaysShowNotifications
|
||||||
|
|
||||||
state.allowedNotificationTypes = new Set(
|
state.allowedNotificationTypes = new Set(
|
||||||
notificationsNativeArray
|
notificationsNativeArray
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue