Merge pull request #500 from YunoHost/fix-domains

fix main_domain api call with ugly cache override from domain list
This commit is contained in:
Alexandre Aubin 2023-01-06 17:55:18 +01:00 committed by GitHub
commit 180b172f53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 10 deletions

View file

@ -30,8 +30,9 @@ export default {
}),
mutations: {
'SET_DOMAINS' (state, [domains]) {
'SET_DOMAINS' (state, [{ domains, main }]) {
state.domains = domains
state.main_domain = main
},
'SET_DOMAINS_DETAILS' (state, [name, details]) {
@ -58,9 +59,10 @@ export default {
state.domains.splice(state.domains.indexOf(domain), 1)
},
'SET_MAIN_DOMAIN' (state, [response]) {
state.main_domain = response.current_main_domain
},
// Now applied thru 'SET_DOMAINS'
// 'SET_MAIN_DOMAIN' (state, [response]) {
// state.main_domain = response.current_main_domain
// },
'UPDATE_MAIN_DOMAIN' (state, [domain]) {
state.main_domain = domain
@ -145,7 +147,10 @@ export default {
const ignoreCache = !rootState.cache || noCache || false
if (currentState !== undefined && !ignoreCache) return currentState
return api.fetch('GET', param ? `${uri}/${param}` : uri, null, humanKey, options).then(responseData => {
const data = responseData[storeKey] ? responseData[storeKey] : responseData
// FIXME here's an ugly fix to be able to also cache the main domain when querying domains
const data = storeKey === 'domains'
? responseData
: responseData[storeKey] ? responseData[storeKey] : responseData
commit(
'SET_' + storeKey.toUpperCase(),
[param, data, extraParams].filter(item => !isEmptyValue(item))

View file

@ -115,7 +115,6 @@ export default {
return {
queries: [
['GET', { uri: 'domains', storeKey: 'domains' }],
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
['GET', { uri: 'domains', storeKey: 'domains_details', param: this.name }],
['GET', `domains/${this.name}/config?full`]
],

View file

@ -54,7 +54,6 @@ export default {
data () {
return {
queries: [
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
['GET', { uri: 'domains', storeKey: 'domains' }]
],
search: '',

View file

@ -57,8 +57,7 @@ export default {
return {
queries: [
['GET', { uri: 'users' }],
['GET', { uri: 'domains' }],
['GET', { uri: 'domains/main', storeKey: 'main_domain' }]
['GET', { uri: 'domains' }]
],
form: {

View file

@ -115,7 +115,6 @@ export default {
return {
queries: [
['GET', { uri: 'users', param: this.name, storeKey: 'users_details' }],
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
['GET', { uri: 'domains' }]
],