1
0

fix: decrease count when cancel status action

This commit is contained in:
三咲智子 Kevin Deng 2023-01-13 02:48:52 +08:00
parent a41a31732b
commit 884227f560
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E

View File

@ -32,8 +32,16 @@ export function useStatusActions(props: StatusActionsProps) {
if (!checkLogin())
return
const prevCount = countField ? status[countField] : undefined
isLoading[action] = true
const isCancel = status[action]
fetchNewStatus().then((newStatus) => {
// when the action is cancelled, the count is not updated highly likely (if they're the same)
// issue of Mastodon API
if (isCancel && countField && prevCount === newStatus[countField])
newStatus[countField] -= 1
Object.assign(status, newStatus)
cacheStatus(newStatus, undefined, true)
}).finally(() => {