mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
fix users state when removing the last user and fix 'cached' check
This commit is contained in:
parent
4dd44ec9d1
commit
ad5c0c0cde
1 changed files with 10 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
import Vue from 'vue'
|
||||
|
||||
import api from '@/api'
|
||||
|
||||
|
||||
export default {
|
||||
state: () => ({
|
||||
domains: undefined, // Array
|
||||
|
@ -37,7 +39,7 @@ export default {
|
|||
},
|
||||
|
||||
'ADD_USERS' (state, user) {
|
||||
if (state.users === undefined) state.users = {}
|
||||
if (!state.users) state.users = {}
|
||||
Vue.set(state.users, user.username, user)
|
||||
},
|
||||
|
||||
|
@ -62,6 +64,9 @@ export default {
|
|||
Vue.delete(state.users_details, username)
|
||||
if (state.users) {
|
||||
Vue.delete(state.users, username)
|
||||
if (Object.keys(state.users).length === 0) {
|
||||
state.users = null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -108,8 +113,8 @@ export default {
|
|||
return { storeKey, param, responseData }
|
||||
})
|
||||
})).then(responsesData => {
|
||||
return responsesData.map(({ storeKey, param, responseData, cached = null }) => {
|
||||
if (cached) return cached
|
||||
return responsesData.map(({ storeKey, param, responseData, cached = undefined }) => {
|
||||
if (cached !== undefined) return cached
|
||||
const data = responseData[storeKey] ? responseData[storeKey] : responseData
|
||||
commit('SET_' + storeKey.toUpperCase(), param ? [param, data] : data)
|
||||
return param ? state[storeKey][param] : state[storeKey]
|
||||
|
@ -146,8 +151,8 @@ export default {
|
|||
users: state => state.users,
|
||||
|
||||
userNames: state => {
|
||||
if (state.users !== undefined) return Object.keys(state.users)
|
||||
return undefined
|
||||
if (state.users) return Object.keys(state.users)
|
||||
return []
|
||||
},
|
||||
|
||||
usersAsChoices: state => {
|
||||
|
|
Loading…
Reference in a new issue