Skip to content

Commit a2005fe

Browse files
authored
Merge pull request #3835 from element-hq/redundant-pip
Avoid redundantly showing the local user in the PiP tile
2 parents 99ba23b + f7488a0 commit a2005fe

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

src/state/CallViewModel/CallViewModel.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,53 @@ describe.each([
750750
});
751751
});
752752

753+
test("PiP tile in expanded spotlight layout avoids redundantly showing local user", () => {
754+
withTestScheduler(({ behavior, schedule, expectObservable }) => {
755+
// Switch to spotlight immediately
756+
const modeInputMarbles = " s";
757+
// And expand the spotlight immediately
758+
const expandInputMarbles = " a";
759+
// First no one else is in the call, then Alice joins
760+
const participantInputMarbles = "ab";
761+
// First local user should be in the spotlight, then they appear in PiP
762+
// only once Alice has joined
763+
const expectedLayoutMarbles = " ab";
764+
765+
withCallViewModel(
766+
{
767+
rtcMembers$: behavior(participantInputMarbles, {
768+
a: [localRtcMember],
769+
b: [localRtcMember, aliceRtcMember],
770+
}),
771+
},
772+
(vm) => {
773+
schedule(modeInputMarbles, {
774+
s: () => vm.setGridMode("spotlight"),
775+
});
776+
schedule(expandInputMarbles, {
777+
a: () => vm.toggleSpotlightExpanded$.value!(),
778+
});
779+
780+
expectObservable(summarizeLayout$(vm.layout$)).toBe(
781+
expectedLayoutMarbles,
782+
{
783+
a: {
784+
type: "spotlight-expanded",
785+
spotlight: [`${localId}:0`],
786+
pip: undefined,
787+
},
788+
b: {
789+
type: "spotlight-expanded",
790+
spotlight: [`${aliceId}:0`],
791+
pip: `${localId}:0`,
792+
},
793+
},
794+
);
795+
},
796+
);
797+
});
798+
});
799+
753800
test("spotlight remembers whether it's expanded", () => {
754801
withTestScheduler(({ schedule, expectObservable }) => {
755802
// Start in spotlight mode, then switch to grid and back to spotlight a

src/state/CallViewModel/CallViewModel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ export function createCallViewModel$(
951951

952952
const spotlightAndPip$ = scope.behavior<{
953953
spotlight: MediaViewModel[];
954-
pip$: Behavior<UserMediaViewModel | undefined>;
954+
pip$: Observable<UserMediaViewModel | undefined>;
955955
}>(
956956
ringingMedia$.pipe(
957957
switchMap((ringingMedia) => {
@@ -966,7 +966,10 @@ export function createCallViewModel$(
966966
return spotlightSpeaker$.pipe(
967967
map((speaker) => ({
968968
spotlight: speaker ? [speaker] : [],
969-
pip$: localUserMediaForPip$,
969+
// Hide PiP if redundant (i.e. if local user is already in spotlight)
970+
pip$: localUserMediaForPip$.pipe(
971+
map((m) => (m === speaker ? undefined : m)),
972+
),
970973
})),
971974
);
972975
}),

0 commit comments

Comments
 (0)