fix(follow-me-pinning) Fix pin/unpin when follow-me (#12911)

This commit is contained in:
Horatiu Muresan 2023-02-15 19:08:08 +02:00 committed by GitHub
parent 456ce38a10
commit a12f7fc4d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -9,7 +9,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
import { updateSettings } from '../base/settings/actions';
// eslint-disable-next-line lines-around-comment
// @ts-ignore
import { addStageParticipant, setFilmstripVisible } from '../filmstrip/actions';
import { addStageParticipant, removeStageParticipant, setFilmstripVisible } from '../filmstrip/actions';
import { setTileView } from '../video-layout/actions.any';
import {
@ -180,9 +180,19 @@ function _onFollowMeCommand(attributes: any = {}, id: string, store: IStore) {
if (attributes.pinnedStageParticipants !== undefined) {
const stageParticipants = JSON.parse(attributes.pinnedStageParticipants);
let oldStageParticipants = [];
if (!_.isEqual(stageParticipants, oldState.pinnedStageParticipants)) {
stageParticipants.forEach((p: { participantId: string; }) =>
if (oldState.pinnedStageParticipants !== undefined) {
oldStageParticipants = JSON.parse(oldState.pinnedStageParticipants);
}
if (!_.isEqual(stageParticipants, oldStageParticipants)) {
const toRemove = _.differenceWith(oldStageParticipants, stageParticipants, _.isEqual);
const toAdd = _.differenceWith(stageParticipants, oldStageParticipants, _.isEqual);
toRemove.forEach((p: { participantId: string; }) =>
store.dispatch(removeStageParticipant(p.participantId)));
toAdd.forEach((p: { participantId: string; }) =>
store.dispatch(addStageParticipant(p.participantId, true)));
}
}