fix(filmstrip) Fix stage filmstrip (#12209)

Use new settings action to determine when max has been reduced
This commit is contained in:
Robert Pintilii 2022-09-21 14:57:40 +03:00 committed by GitHub
parent 63b6b5a72d
commit dd4d49a591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 17 deletions

View File

@ -25,7 +25,6 @@ import {
CLEAR_STAGE_PARTICIPANTS,
REMOVE_STAGE_PARTICIPANT,
RESIZE_FILMSTRIP,
SET_MAX_STAGE_PARTICIPANTS,
SET_USER_FILMSTRIP_WIDTH,
TOGGLE_PIN_STAGE_PARTICIPANT
} from './actionTypes';
@ -137,6 +136,19 @@ MiddlewareRegistry.register(store => next => action => {
}
}
}
if (action.settings?.maxStageParticipants !== undefined) {
const maxParticipants = action.settings.maxStageParticipants;
const { activeParticipants } = store.getState()['features/filmstrip'];
const newMax = Math.min(MAX_ACTIVE_PARTICIPANTS, maxParticipants);
if (newMax < activeParticipants.length) {
const toRemove = activeParticipants.slice(0, activeParticipants.length - newMax);
batch(() => {
toRemove.forEach(p => store.dispatch(removeStageParticipant(p.participantId)));
});
}
}
break;
}
case SET_USER_FILMSTRIP_WIDTH: {
@ -265,22 +277,6 @@ MiddlewareRegistry.register(store => next => action => {
}
break;
}
case SET_MAX_STAGE_PARTICIPANTS: {
const { maxParticipants } = action;
const { activeParticipants } = store.getState()['features/filmstrip'];
const newMax = Math.min(MAX_ACTIVE_PARTICIPANTS, maxParticipants);
action.maxParticipants = newMax;
if (newMax < activeParticipants.length) {
const toRemove = activeParticipants.slice(0, activeParticipants.length - newMax);
batch(() => {
toRemove.forEach(p => store.dispatch(removeStageParticipant(p.participantId)));
});
}
break;
}
case TOGGLE_PIN_STAGE_PARTICIPANT: {
const { dispatch, getState } = store;
const state = getState();