fix: update cache + timeline when items are updated/deleted (#556)

This commit is contained in:
Daniel Roe 2022-12-25 15:52:37 +01:00 committed by GitHub
parent 720b5114af
commit dc76ab2477
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 15 deletions

View file

@ -33,11 +33,13 @@ export function useStatusActions(props: StatusActionsProps) {
isLoading[action] = true
fetchNewStatus().then((newStatus) => {
Object.assign(status, newStatus)
cacheStatus(newStatus, undefined, true)
}).finally(() => {
isLoading[action] = false
})
// Optimistic update
status[action] = !status[action]
cacheStatus(status, undefined, true)
if (countField)
status[countField] += status[action] ? 1 : -1
}