useIncrementEntity: fix optimistic counter

environments/review-group-requ-7youoa/deployments/2945
Alex Gleason 2023-03-22 19:58:40 -05:00
rodzic 402daec9c3
commit 6929975aaa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -21,9 +21,9 @@ function useIncrementEntity<T = unknown>(
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
return async function incrementEntity(entityId: string): Promise<void> { return async function incrementEntity(entityId: string): Promise<void> {
dispatch(incrementEntities(entityType, listKey, diff));
try { try {
await incrementFn(entityId); await incrementFn(entityId);
dispatch(incrementEntities(entityType, listKey, diff));
} catch (e) { } catch (e) {
dispatch(incrementEntities(entityType, listKey, diff * -1)); dispatch(incrementEntities(entityType, listKey, diff * -1));
} }