fix: Batch actions.

This commit is contained in:
Hristo Terezov 2023-02-23 14:59:00 -06:00
parent e5a170fb28
commit 4aea40d34f
2 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import { batch } from 'react-redux';
import { AnyAction } from 'redux'; import { AnyAction } from 'redux';
import { IStore } from '../app/types'; import { IStore } from '../app/types';
@ -49,11 +50,14 @@ MiddlewareRegistry.register(({ dispatch, getState }: IStore) => (next: Function)
const stats = filterBySearchCriteria(state, speakerStats); const stats = filterBySearchCriteria(state, speakerStats);
const pendingReorder = getPendingReorder(state); const pendingReorder = getPendingReorder(state);
batch(() => {
if (pendingReorder) { if (pendingReorder) {
dispatch(updateSortedSpeakerStatsIds(getSortedSpeakerStatsIds(state, stats) ?? [])); dispatch(updateSortedSpeakerStatsIds(getSortedSpeakerStatsIds(state, stats) ?? []));
} }
dispatch(updateStats(stats)); dispatch(updateStats(stats));
});
} }
break; break;

View File

@ -1,3 +1,5 @@
import { batch } from 'react-redux';
import { import {
HIDDEN_PARTICIPANT_JOINED, HIDDEN_PARTICIPANT_JOINED,
HIDDEN_PARTICIPANT_LEFT, HIDDEN_PARTICIPANT_LEFT,
@ -64,8 +66,10 @@ MiddlewareRegistry.register(store => next => action => {
if (potentialTranscriberJIDs.includes(participant.id) if (potentialTranscriberJIDs.includes(participant.id)
&& participant.name === TRANSCRIBER_DISPLAY_NAME) { && participant.name === TRANSCRIBER_DISPLAY_NAME) {
batch(() => {
store.dispatch(transcriberJoined(participant.id)); store.dispatch(transcriberJoined(participant.id));
store.dispatch(hidePendingTranscribingNotification()); store.dispatch(hidePendingTranscribingNotification());
});
} }
break; break;