mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
fix: cache payloads + delay data deletion to avoid view error before routing
This commit is contained in:
parent
fa29cbb499
commit
5ad3738861
1 changed files with 13 additions and 2 deletions
|
@ -43,7 +43,7 @@ const useData = createGlobalState(() => {
|
|||
}
|
||||
} else if (key === 'userDetails' && param) {
|
||||
if (method === 'GET' || method === 'PUT') {
|
||||
userDetails.value[param] = payload[param]
|
||||
userDetails.value[param] = payload
|
||||
} else if (method === 'DELETE') {
|
||||
delete userDetails.value[param]
|
||||
delete users.value[param]
|
||||
|
@ -79,6 +79,8 @@ const useData = createGlobalState(() => {
|
|||
delete domainDetails.value[param]
|
||||
}
|
||||
}
|
||||
} else if (key === 'mainDomain' && method === 'PUT' && param) {
|
||||
mainDomain.value = param
|
||||
} else if (key === 'domainDetails' && param && method === 'GET') {
|
||||
domainDetails.value[param] = payload
|
||||
} else {
|
||||
|
@ -239,7 +241,16 @@ export function useCache<T extends any = any>(
|
|||
}
|
||||
return (isEmptyValue(d) ? undefined : d) as T
|
||||
}),
|
||||
update: (payload: T) => data.update(method, payload, key, param),
|
||||
update: (payload: T) => {
|
||||
if (method === 'DELETE') {
|
||||
// Update the cache with a delay to avoid current view to error out since there's no data anymore
|
||||
setTimeout(() => {
|
||||
data.update(method, payload, key, param)
|
||||
}, 100)
|
||||
} else {
|
||||
data.update(method, payload, key, param)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue