From 884227f5601790253edf740d28de51cb4edab2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 13 Jan 2023 02:48:52 +0800 Subject: [PATCH] fix: decrease count when cancel status action --- composables/masto/status.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/composables/masto/status.ts b/composables/masto/status.ts index 9a7935f327..9669cd9527 100644 --- a/composables/masto/status.ts +++ b/composables/masto/status.ts @@ -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(() => {