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();
|
||||
|
||||
return async function incrementEntity(entityId: string): Promise<void> {
|
||||
dispatch(incrementEntities(entityType, listKey, diff));
|
||||
try {
|
||||
await incrementFn(entityId);
|
||||
dispatch(incrementEntities(entityType, listKey, diff));
|
||||
} catch (e) {
|
||||
dispatch(incrementEntities(entityType, listKey, diff * -1));
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue