From 6929975aaa5afee926d6afa3788cdc5b830caa68 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 22 Mar 2023 19:58:40 -0500 Subject: [PATCH] useIncrementEntity: fix optimistic counter --- app/soapbox/entity-store/hooks/useIncrementEntity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/soapbox/entity-store/hooks/useIncrementEntity.ts b/app/soapbox/entity-store/hooks/useIncrementEntity.ts index 5f87fdea4..c0cbd133d 100644 --- a/app/soapbox/entity-store/hooks/useIncrementEntity.ts +++ b/app/soapbox/entity-store/hooks/useIncrementEntity.ts @@ -21,9 +21,9 @@ function useIncrementEntity( const dispatch = useAppDispatch(); return async function incrementEntity(entityId: string): Promise { + dispatch(incrementEntities(entityType, listKey, diff)); try { await incrementFn(entityId); - dispatch(incrementEntities(entityType, listKey, diff)); } catch (e) { dispatch(incrementEntities(entityType, listKey, diff * -1)); }