fix(follow-me-pinning) Fix pin/unpin when follow-me (#12911)
This commit is contained in:
parent
456ce38a10
commit
a12f7fc4d2
|
@ -9,7 +9,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||||
import { updateSettings } from '../base/settings/actions';
|
import { updateSettings } from '../base/settings/actions';
|
||||||
// eslint-disable-next-line lines-around-comment
|
// eslint-disable-next-line lines-around-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { addStageParticipant, setFilmstripVisible } from '../filmstrip/actions';
|
import { addStageParticipant, removeStageParticipant, setFilmstripVisible } from '../filmstrip/actions';
|
||||||
import { setTileView } from '../video-layout/actions.any';
|
import { setTileView } from '../video-layout/actions.any';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -180,9 +180,19 @@ function _onFollowMeCommand(attributes: any = {}, id: string, store: IStore) {
|
||||||
|
|
||||||
if (attributes.pinnedStageParticipants !== undefined) {
|
if (attributes.pinnedStageParticipants !== undefined) {
|
||||||
const stageParticipants = JSON.parse(attributes.pinnedStageParticipants);
|
const stageParticipants = JSON.parse(attributes.pinnedStageParticipants);
|
||||||
|
let oldStageParticipants = [];
|
||||||
|
|
||||||
if (!_.isEqual(stageParticipants, oldState.pinnedStageParticipants)) {
|
if (oldState.pinnedStageParticipants !== undefined) {
|
||||||
stageParticipants.forEach((p: { participantId: string; }) =>
|
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)));
|
store.dispatch(addStageParticipant(p.participantId, true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue