Migrate interface module to store

This commit is contained in:
Sean King 2023-04-05 21:06:37 -06:00
commit b1dcea0199
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
33 changed files with 244 additions and 77 deletions

View file

@ -19,6 +19,7 @@ import {
import {
faWindowMinimize
} from '@fortawesome/free-regular-svg-icons'
import { useInterfaceStore } from '../../stores/interface'
const PLEROMAFE_SETTINGS_MAJOR_VERSION = 1
const PLEROMAFE_SETTINGS_MINOR_VERSION = 0
@ -64,10 +65,10 @@ const SettingsModal = {
},
methods: {
closeModal () {
this.$store.dispatch('closeSettingsModal')
useInterfaceStore().closeSettingsModal()
},
peekModal () {
this.$store.dispatch('togglePeekSettingsModal')
useInterfaceStore().togglePeekSettingsModal()
},
importValidator (data) {
if (!Array.isArray(data._pleroma_settings_version)) {
@ -99,7 +100,7 @@ const SettingsModal = {
}
if (minor > PLEROMAFE_SETTINGS_MINOR_VERSION) {
this.$store.dispatch('pushGlobalNotice', {
useInterfaceStore().pushGlobalNotice({
level: 'warning',
messageKey: 'settings.file_export_import.errors.file_slightly_new'
})
@ -109,9 +110,9 @@ const SettingsModal = {
},
onImportFailure (result) {
if (result.error) {
this.$store.dispatch('pushGlobalNotice', { messageKey: 'settings.invalid_settings_imported', level: 'error' })
useInterfaceStore().pushGlobalNotice({ messageKey: 'settings.invalid_settings_imported', level: 'error' })
} else {
this.$store.dispatch('pushGlobalNotice', { ...result.validationResult, level: 'error' })
useInterfaceStore().pushGlobalNotice({ ...result.validationResult, level: 'error' })
}
},
onImport (data) {
@ -151,16 +152,16 @@ const SettingsModal = {
},
computed: {
currentSaveStateNotice () {
return this.$store.state.interface.settings.currentSaveStateNotice
return useInterfaceStore().settings.currentSaveStateNotice
},
modalActivated () {
return this.$store.state.interface.settingsModalState !== 'hidden'
return useInterfaceStore().settingsModalState !== 'hidden'
},
modalOpenedOnce () {
return this.$store.state.interface.settingsModalLoaded
return useInterfaceStore().settingsModalLoaded
},
modalPeeked () {
return this.$store.state.interface.settingsModalState === 'minimized'
return useInterfaceStore().settingsModalState === 'minimized'
},
expertLevel: {
get () {

View file

@ -21,6 +21,7 @@ import {
faEyeSlash,
faInfo
} from '@fortawesome/free-solid-svg-icons'
import { useInterfaceStore } from '../../stores/interface'
library.add(
faWrench,
@ -52,15 +53,15 @@ const SettingsModalContent = {
return !!this.$store.state.users.currentUser
},
open () {
return this.$store.state.interface.settingsModalState !== 'hidden'
return useInterfaceStore().settingsModalState !== 'hidden'
},
bodyLock () {
return this.$store.state.interface.settingsModalState === 'visible'
return useInterfaceStore().settingsModalState === 'visible'
}
},
methods: {
onOpen () {
const targetTab = this.$store.state.interface.settingsModalTargetTab
const targetTab = useInterfaceStore().settingsModalTargetTab
// We're being told to open in specific tab
if (targetTab) {
const tabIndex = this.$refs.tabSwitcher.$slots.default().findIndex(elm => {
@ -72,7 +73,7 @@ const SettingsModalContent = {
}
// Clear the state of target tab, so that next time settings is opened
// it doesn't force it.
this.$store.dispatch('clearSettingsModalTargetTab')
useInterfaceStore().clearSettingsModalTargetTab()
}
},
mounted () {

View file

@ -20,6 +20,7 @@ import {
faPlus,
faCircleNotch
} from '@fortawesome/free-solid-svg-icons'
import { useInterfaceStore } from '../../../stores/interface'
library.add(
faTimes,
@ -166,7 +167,7 @@ const ProfileTab = {
if (file.size > this.$store.state.instance[slot + 'limit']) {
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])
this.$store.dispatch('pushGlobalNotice', {
useInterfaceStore().pushGlobalNotice({
messageKey: 'upload.error.message',
messageArgs: [
this.$t('upload.error.file_too_big', {
@ -257,7 +258,7 @@ const ProfileTab = {
.finally(() => { this.backgroundUploading = false })
},
displayUploadError (error) {
this.$store.dispatch('pushGlobalNotice', {
useInterfaceStore().pushGlobalNotice({
messageKey: 'upload.error.message',
messageArgs: [error.message],
level: 'error'

View file

@ -38,6 +38,7 @@ import Checkbox from 'src/components/checkbox/checkbox.vue'
import Select from 'src/components/select/select.vue'
import Preview from './preview.vue'
import { useInterfaceStore } from '../../../../stores/interface'
// List of color values used in v1
const v1OnlyNames = [
@ -548,7 +549,7 @@ export default {
this.loadTheme(parsed, 'file', forceSource)
},
onImportFailure (result) {
this.$store.dispatch('pushGlobalNotice', { messageKey: 'settings.invalid_theme_imported', level: 'error' })
useInterfaceStore().pushGlobalNotice({ messageKey: 'settings.invalid_theme_imported', level: 'error' })
},
importValidator (parsed) {
const version = parsed._pleroma_theme_version