forked from Mirrors/elk
fix: decrease count when cancel status action
This commit is contained in:
parent
a41a31732b
commit
884227f560
1 changed files with 8 additions and 0 deletions
|
@ -32,8 +32,16 @@ export function useStatusActions(props: StatusActionsProps) {
|
||||||
if (!checkLogin())
|
if (!checkLogin())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
const prevCount = countField ? status[countField] : undefined
|
||||||
|
|
||||||
isLoading[action] = true
|
isLoading[action] = true
|
||||||
|
const isCancel = status[action]
|
||||||
fetchNewStatus().then((newStatus) => {
|
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)
|
Object.assign(status, newStatus)
|
||||||
cacheStatus(newStatus, undefined, true)
|
cacheStatus(newStatus, undefined, true)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
|
Loading…
Reference in a new issue