some initial work on moving instance settings to pinia
This commit is contained in:
parent
20071d5a11
commit
9452b3084a
10 changed files with 559 additions and 195 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { cloneDeep, get, isEqual, set } from 'lodash'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance'
|
||||
import { useServerSideStorageStore } from 'src/stores/serverSideStorage'
|
||||
import DraftButtons from './draft_buttons.vue'
|
||||
import ModifiedIndicator from './modified_indicator.vue'
|
||||
|
|
@ -228,7 +229,7 @@ export default {
|
|||
configSource() {
|
||||
switch (this.realSource) {
|
||||
case 'server-side':
|
||||
return useServerSideStorageStore().prefsStorage
|
||||
return useServerSideStorageStore().mergedConfig
|
||||
case 'profile':
|
||||
return this.$store.state.profileConfig
|
||||
case 'admin':
|
||||
|
|
@ -243,36 +244,10 @@ export default {
|
|||
}
|
||||
switch (this.realSource) {
|
||||
case 'server-side': {
|
||||
return (path, value, operator) => {
|
||||
const folder = path.split('.')[0]
|
||||
if (folder === 'collections' || folder === 'objectCollections') {
|
||||
switch (operator) {
|
||||
case 'add':
|
||||
useServerSideStorageStore().addCollectionPreference({
|
||||
path,
|
||||
value,
|
||||
})
|
||||
useServerSideStorageStore().pushServerSideStorage()
|
||||
break
|
||||
case 'remove':
|
||||
useServerSideStorageStore().removeCollectionPreference({
|
||||
path,
|
||||
value,
|
||||
})
|
||||
useServerSideStorageStore().pushServerSideStorage()
|
||||
break
|
||||
default:
|
||||
console.error(
|
||||
`Unknown server-side collection operator ${operator}, ignoring`,
|
||||
)
|
||||
break
|
||||
}
|
||||
} else if (folder === 'simple') {
|
||||
useServerSideStorageStore().setPreference({ path, value })
|
||||
useServerSideStorageStore().pushServerSideStorage()
|
||||
} else {
|
||||
console.error(`Unknown server-side folder ${folder}, ignoring`)
|
||||
}
|
||||
return (originalPath, value, operator) => {
|
||||
const path = `simple.${originalPath}`
|
||||
useServerSideStorageStore().setPreference({ path, value })
|
||||
useServerSideStorageStore().pushServerSideStorage()
|
||||
}
|
||||
}
|
||||
case 'profile':
|
||||
|
|
@ -299,10 +274,7 @@ export default {
|
|||
case 'profile':
|
||||
return {}
|
||||
case 'server-side':
|
||||
return get(
|
||||
this.$store.getters.defaultConfig,
|
||||
this.path.split(/\./g).slice(1),
|
||||
)
|
||||
return get(useInstanceStore().prefsStorage, this.path)
|
||||
default:
|
||||
return get(this.$store.getters.defaultConfig, this.path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.alwaysShowSubjectInput"
|
||||
path="alwaysShowSubjectInput"
|
||||
>
|
||||
{{ $t('settings.subject_input_always_show') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.minimalScopesMode"
|
||||
path="minimalScopesMode"
|
||||
>
|
||||
{{ $t('settings.minimal_scopes_mode') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -22,14 +22,14 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hidePostStats"
|
||||
path="hidePostStats"
|
||||
>
|
||||
{{ $t('settings.hide_post_stats') }}
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
path="simple.hideUserStats"
|
||||
path="hideUserStats"
|
||||
source="server-side"
|
||||
>
|
||||
{{ $t('settings.hide_user_stats') }}
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hideBotIndication"
|
||||
path="hideBotIndication"
|
||||
>
|
||||
{{ $t('settings.hide_actor_type_indication') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hideScrobbles"
|
||||
path="hideScrobbles"
|
||||
>
|
||||
{{ $t('settings.hide_scrobbles') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
<UnitSetting
|
||||
key="hideScrobblesAfter"
|
||||
source="server-side"
|
||||
path="simple.hideScrobblesAfter"
|
||||
path="hideScrobblesAfter"
|
||||
:units="['m', 'h', 'd']"
|
||||
unit-set="time"
|
||||
>
|
||||
|
|
@ -70,7 +70,7 @@
|
|||
<li>
|
||||
<IntegerSetting
|
||||
source="server-side"
|
||||
path="simple.maxThumbnails"
|
||||
path="maxThumbnails"
|
||||
:min="0"
|
||||
>
|
||||
{{ $t('settings.max_thumbnails') }}
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hideAttachments"
|
||||
path="hideAttachments"
|
||||
>
|
||||
{{ $t('settings.hide_attachments_in_tl') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hideAttachmentsInConv"
|
||||
path="hideAttachmentsInConv"
|
||||
>
|
||||
{{ $t('settings.hide_attachments_in_convo') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
<li>
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.userCardHidePersonalMarks"
|
||||
path="userCardHidePersonalMarks"
|
||||
>
|
||||
{{ $t('settings.user_card_hide_personal_marks') }}
|
||||
</BooleanSetting>
|
||||
|
|
@ -103,7 +103,7 @@
|
|||
<li v-if="instanceShoutboxPresent">
|
||||
<BooleanSetting
|
||||
source="server-side"
|
||||
path="simple.hideShoutbox"
|
||||
path="hideShoutbox"
|
||||
>
|
||||
{{ $t('settings.hide_shoutbox') }}
|
||||
</BooleanSetting>
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
const currentIndex = this.$store.state.instance.themesIndex
|
||||
const currentIndex = this.$store.state.instance.instanceThemesIndex
|
||||
|
||||
let promise
|
||||
if (currentIndex) {
|
||||
|
|
@ -134,8 +134,8 @@ export default {
|
|||
promise = useInterfaceStore().fetchThemesIndex()
|
||||
}
|
||||
|
||||
promise.then((themesIndex) => {
|
||||
Object.values(themesIndex).forEach((themeFunc) => {
|
||||
promise.then((instanceThemesIndex) => {
|
||||
Object.values(instanceThemesIndex).forEach((themeFunc) => {
|
||||
themeFunc().then(
|
||||
(themeData) => themeData && this.availableStyles.push(themeData),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue