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 { IStore } from '../app/types';
@ -49,11 +50,14 @@ MiddlewareRegistry.register(({ dispatch, getState }: IStore) => (next: Function)
const stats = filterBySearchCriteria(state, speakerStats);
const pendingReorder = getPendingReorder(state);
if (pendingReorder) {
dispatch(updateSortedSpeakerStatsIds(getSortedSpeakerStatsIds(state, stats) ?? []));
}
batch(() => {
if (pendingReorder) {
dispatch(updateSortedSpeakerStatsIds(getSortedSpeakerStatsIds(state, stats) ?? []));
}
dispatch(updateStats(stats));
});
dispatch(updateStats(stats));
}
break;

View File

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