fix(settings): Save account management settings in local storage

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/44092/head
Ferdinand Thiessen 2 months ago
parent cbdadba2e3
commit 78bcab1aac
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400

@ -74,7 +74,6 @@
</template>
<script>
import { getBuilder } from '@nextcloud/browser-storage'
import { formatFileSize, parseFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
@ -103,15 +102,6 @@ export default {
},
},
setup() {
const localStorage = getBuilder('settings')
.persist(true)
.clearOnLogout(true)
.build()
return { localStorage }
},
data() {
return {
selectedQuota: false,
@ -139,37 +129,37 @@ export default {
showLanguages: {
get() {
return this.getLocalstorage('showLanguages')
return this.showConfig.showLanguages
},
set(status) {
this.setLocalStorage('showLanguages', status)
this.setShowConfig('showLanguages', status)
},
},
showLastLogin: {
get() {
return this.getLocalstorage('showLastLogin')
return this.showConfig.showLastLogin
},
set(status) {
this.setLocalStorage('showLastLogin', status)
this.setShowConfig('showLastLogin', status)
},
},
showUserBackend: {
get() {
return this.getLocalstorage('showUserBackend')
return this.showConfig.showUserBackend
},
set(status) {
this.setLocalStorage('showUserBackend', status)
this.setShowConfig('showUserBackend', status)
},
},
showStoragePath: {
get() {
return this.getLocalstorage('showStoragePath')
return this.showConfig.showStoragePath
},
set(status) {
this.setLocalStorage('showStoragePath', status)
this.setShowConfig('showStoragePath', status)
},
},
@ -221,18 +211,8 @@ export default {
},
methods: {
getLocalstorage(key) {
// force initialization
const localConfig = JSON.parse(this.localStorage.getItem(key) ?? 'null')
// if localstorage is null, fallback to original values
this.$store.commit('setShowConfig', { key, value: localConfig !== null ? localConfig === 'true' : this.showConfig[key] })
return this.showConfig[key]
},
setLocalStorage(key, status) {
setShowConfig(key, status) {
this.$store.commit('setShowConfig', { key, value: status })
this.localStorage.setItem(key, JSON.stringify(status))
return status
},
/**

@ -27,6 +27,7 @@
*
*/
import { getBuilder } from '@nextcloud/browser-storage'
import { getCapabilities } from '@nextcloud/capabilities'
import { parseFileSize } from '@nextcloud/files'
import { generateOcsUrl } from '@nextcloud/router'
@ -35,6 +36,8 @@ import axios from '@nextcloud/axios'
import api from './api.js'
import logger from '../logger.ts'
const localStorage = getBuilder('settings').persist(true).build()
const orderGroups = function(groups, orderBy) {
/* const SORT_USERCOUNT = 1;
* const SORT_GROUPNAME = 2;
@ -69,11 +72,11 @@ const state = {
disabledUsersLimit: 25,
userCount: 0,
showConfig: {
showStoragePath: false,
showUserBackend: false,
showLastLogin: false,
showNewUserForm: false,
showLanguages: false,
showStoragePath: localStorage.getItem('account_settings__showStoragePath') === 'true',
showUserBackend: localStorage.getItem('account_settings__showUserBackend') === 'true',
showLastLogin: localStorage.getItem('account_settings__showLastLogin') === 'true',
showNewUserForm: localStorage.getItem('account_settings__showNewUserForm') === 'true',
showLanguages: localStorage.getItem('account_settings__showLanguages') === 'true',
},
}
@ -248,6 +251,7 @@ const mutations = {
},
setShowConfig(state, { key, value }) {
localStorage.setItem(`account_settings__${key}`, JSON.stringify(value))
state.showConfig[key] = value
},
}

Loading…
Cancel
Save