kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
useIncrementEntity: fix optimistic counter
rodzic
402daec9c3
commit
6929975aaa
|
@ -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));
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue