fix: mutation errors by make a copy of the store settings

This commit is contained in:
Dominik Pschenitschni 2021-10-02 23:30:06 +02:00
parent eec02a55a4
commit 3750b0f78b
No known key found for this signature in database
GPG key ID: B257AC0149F43A77

View file

@ -298,7 +298,6 @@ import EmailUpdateModel from '../../models/emailUpdate'
import TotpModel from '../../models/totp' import TotpModel from '../../models/totp'
import TotpService from '../../services/totp' import TotpService from '../../services/totp'
import UserSettingsService from '../../services/userSettings' import UserSettingsService from '../../services/userSettings'
import UserSettingsModel from '../../models/userSettings'
import {playSoundWhenDoneKey} from '@/helpers/playPop' import {playSoundWhenDoneKey} from '@/helpers/playPop'
import {availableLanguages, saveLanguage, getCurrentLanguage} from '@/i18n' import {availableLanguages, saveLanguage, getCurrentLanguage} from '@/i18n'
import {getQuickAddMagicMode, setQuickAddMagicMode} from '../../helpers/quickAddMagicMode' import {getQuickAddMagicMode, setQuickAddMagicMode} from '../../helpers/quickAddMagicMode'
@ -312,6 +311,10 @@ import ListSearch from '@/components/tasks/partials/listSearch.vue'
import UserSettingsDeletion from '../../components/user/settings/deletion' import UserSettingsDeletion from '../../components/user/settings/deletion'
import DataExport from '../../components/user/settings/data-export' import DataExport from '../../components/user/settings/data-export'
function getPlaySoundWhenDoneSetting() {
return localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
}
export default { export default {
name: 'Settings', name: 'Settings',
data() { data() {
@ -330,15 +333,13 @@ export default {
totpConfirmPasscode: '', totpConfirmPasscode: '',
totpDisableForm: false, totpDisableForm: false,
totpDisablePassword: '', totpDisablePassword: '',
playSoundWhenDone: false, playSoundWhenDone: getPlaySoundWhenDoneSetting(),
language: getCurrentLanguage(), language: getCurrentLanguage(),
quickAddMagicMode: getQuickAddMagicMode(), quickAddMagicMode: getQuickAddMagicMode(),
quickAddMagicPrefixes: PrefixMode, quickAddMagicPrefixes: PrefixMode,
settings: UserSettingsModel, settings: { ...this.$store.state.auth.settings },
userSettingsService: new UserSettingsService(), userSettingsService: new UserSettingsService(),
defaultList: null,
} }
}, },
components: { components: {
@ -348,9 +349,6 @@ export default {
DataExport, DataExport,
}, },
created() { created() {
this.settings = this.$store.state.auth.settings
this.playSoundWhenDone = localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
this.defaultList = this.$store.getters['lists/getListById'](this.settings.defaultListId)
this.totpStatus() this.totpStatus()
}, },
mounted() { mounted() {
@ -358,6 +356,9 @@ export default {
this.anchorHashCheck() this.anchorHashCheck()
}, },
computed: { computed: {
defaultList() {
return this.$store.getters['lists/getListById'](this.settings.defaultListId)
},
caldavUrl() { caldavUrl() {
let apiBase = window.API_URL.replace('/api/v1', '') let apiBase = window.API_URL.replace('/api/v1', '')
if (apiBase === '') { // Frontend and api on the same host which means we need to prefix the frontend url if (apiBase === '') { // Frontend and api on the same host which means we need to prefix the frontend url