fix: Automatically switch to spotlight if remote screenshare
This commit is contained in:
@@ -267,7 +267,7 @@ describe("CallViewModel", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip("screen sharing activates spotlight layout", () => {
|
test("screen sharing activates spotlight layout", () => {
|
||||||
withTestScheduler(({ behavior, schedule, expectObservable }) => {
|
withTestScheduler(({ behavior, schedule, expectObservable }) => {
|
||||||
// Start with no screen shares, then have Alice and Bob share their screens,
|
// Start with no screen shares, then have Alice and Bob share their screens,
|
||||||
// then return to no screen shares, then have just Alice share for a bit
|
// then return to no screen shares, then have just Alice share for a bit
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import {
|
|||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import { type Room as MatrixRoom } from "matrix-js-sdk";
|
import { type Room as MatrixRoom } from "matrix-js-sdk";
|
||||||
import {
|
import {
|
||||||
|
BehaviorSubject,
|
||||||
combineLatest,
|
combineLatest,
|
||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
EMPTY,
|
|
||||||
filter,
|
filter,
|
||||||
fromEvent,
|
fromEvent,
|
||||||
map,
|
map,
|
||||||
@@ -28,7 +28,6 @@ import {
|
|||||||
pairwise,
|
pairwise,
|
||||||
race,
|
race,
|
||||||
scan,
|
scan,
|
||||||
skip,
|
|
||||||
skipWhile,
|
skipWhile,
|
||||||
startWith,
|
startWith,
|
||||||
Subject,
|
Subject,
|
||||||
@@ -992,7 +991,7 @@ export function createCallViewModel$(
|
|||||||
spotlightExpandedToggle$.pipe(accumulate(false, (expanded) => !expanded)),
|
spotlightExpandedToggle$.pipe(accumulate(false, (expanded) => !expanded)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const gridModeUserSelection$ = new Subject<GridMode>();
|
const gridModeUserSelection$ = new BehaviorSubject<GridMode>("grid");
|
||||||
/**
|
/**
|
||||||
* The layout mode of the media tile grid.
|
* The layout mode of the media tile grid.
|
||||||
*/
|
*/
|
||||||
@@ -1001,20 +1000,30 @@ export function createCallViewModel$(
|
|||||||
// automatically switch to spotlight mode and reset when screen sharing ends
|
// automatically switch to spotlight mode and reset when screen sharing ends
|
||||||
scope.behavior<GridMode>(
|
scope.behavior<GridMode>(
|
||||||
gridModeUserSelection$.pipe(
|
gridModeUserSelection$.pipe(
|
||||||
switchMap((userSelection) =>
|
switchMap((userSelection): Observable<GridMode> => {
|
||||||
(userSelection === "spotlight"
|
if (userSelection === "spotlight") {
|
||||||
? EMPTY
|
// If already in spotlight mode, stay there
|
||||||
: combineLatest([hasRemoteScreenShares$, windowMode$]).pipe(
|
return of("spotlight");
|
||||||
skip(userSelection === null ? 0 : 1),
|
} else {
|
||||||
map(
|
// Otherwise, check if there is a remote screen share active
|
||||||
([hasScreenShares, windowMode]): GridMode =>
|
// as this could force us into spotlight mode.
|
||||||
hasScreenShares || windowMode === "flat"
|
return combineLatest([hasRemoteScreenShares$, windowMode$]).pipe(
|
||||||
? "spotlight"
|
map(([hasScreenShares, windowMode]): GridMode => {
|
||||||
: "grid",
|
const isFlatMode = windowMode === "flat";
|
||||||
),
|
if (hasScreenShares || isFlatMode) {
|
||||||
)
|
logger.debug(
|
||||||
).pipe(startWith(userSelection ?? "grid")),
|
`Forcing spotlight mode, hasScreenShares=${hasScreenShares} windowMode=${windowMode}`,
|
||||||
),
|
);
|
||||||
|
// override to spotlight mode
|
||||||
|
return "spotlight";
|
||||||
|
} else {
|
||||||
|
// respect user choice
|
||||||
|
return "grid";
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
"grid",
|
"grid",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user