Skip to content

Commit

Permalink
fix: decrease count when cancel status action
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jan 12, 2023
1 parent a41a317 commit 884227f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions composables/masto/status.ts
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 884227f

Please sign in to comment.