mirror of
https://github.com/vector-im/element-call.git
synced 2024-11-24 00:38:31 +08:00
Use more explicit names and types for LayoutMedia observables
This commit is contained in:
parent
84e172a2ba
commit
40b2b58fc2
@ -672,7 +672,7 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.gridModeUserSelection.next(value);
|
this.gridModeUserSelection.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly gridLayout: Observable<LayoutMedia> = combineLatest(
|
private readonly gridLayoutMedia: Observable<GridLayoutMedia> = combineLatest(
|
||||||
[this.grid, this.spotlight],
|
[this.grid, this.spotlight],
|
||||||
(grid, spotlight) => ({
|
(grid, spotlight) => ({
|
||||||
type: "grid",
|
type: "grid",
|
||||||
@ -683,28 +683,28 @@ export class CallViewModel extends ViewModel {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly spotlightLandscapeLayout: Observable<LayoutMedia> =
|
private readonly spotlightLandscapeLayoutMedia: Observable<SpotlightLandscapeLayoutMedia> =
|
||||||
combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({
|
combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({
|
||||||
type: "spotlight-landscape",
|
type: "spotlight-landscape",
|
||||||
spotlight,
|
spotlight,
|
||||||
grid,
|
grid,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
private readonly spotlightPortraitLayout: Observable<LayoutMedia> =
|
private readonly spotlightPortraitLayoutMedia: Observable<SpotlightPortraitLayoutMedia> =
|
||||||
combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({
|
combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({
|
||||||
type: "spotlight-portrait",
|
type: "spotlight-portrait",
|
||||||
spotlight,
|
spotlight,
|
||||||
grid,
|
grid,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
private readonly spotlightExpandedLayout: Observable<LayoutMedia> =
|
private readonly spotlightExpandedLayoutMedia: Observable<SpotlightExpandedLayoutMedia> =
|
||||||
combineLatest([this.spotlight, this.pip], (spotlight, pip) => ({
|
combineLatest([this.spotlight, this.pip], (spotlight, pip) => ({
|
||||||
type: "spotlight-expanded",
|
type: "spotlight-expanded",
|
||||||
spotlight,
|
spotlight,
|
||||||
pip: pip ?? undefined,
|
pip: pip ?? undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
private readonly oneOnOneLayout: Observable<LayoutMedia | null> =
|
private readonly oneOnOneLayoutMedia: Observable<OneOnOneLayoutMedia | null> =
|
||||||
this.mediaItems.pipe(
|
this.mediaItems.pipe(
|
||||||
map((mediaItems) => {
|
map((mediaItems) => {
|
||||||
if (mediaItems.length !== 2) return null;
|
if (mediaItems.length !== 2) return null;
|
||||||
@ -722,9 +722,8 @@ export class CallViewModel extends ViewModel {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly pipLayout: Observable<LayoutMedia> = this.spotlight.pipe(
|
private readonly pipLayoutMedia: Observable<LayoutMedia> =
|
||||||
map((spotlight) => ({ type: "pip", spotlight })),
|
this.spotlight.pipe(map((spotlight) => ({ type: "pip", spotlight })));
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The media to be used to produce a layout.
|
* The media to be used to produce a layout.
|
||||||
@ -737,24 +736,24 @@ export class CallViewModel extends ViewModel {
|
|||||||
switchMap((gridMode) => {
|
switchMap((gridMode) => {
|
||||||
switch (gridMode) {
|
switch (gridMode) {
|
||||||
case "grid":
|
case "grid":
|
||||||
return this.oneOnOneLayout.pipe(
|
return this.oneOnOneLayoutMedia.pipe(
|
||||||
switchMap((oneOnOne) =>
|
switchMap((oneOnOne) =>
|
||||||
oneOnOne === null ? this.gridLayout : of(oneOnOne),
|
oneOnOne === null ? this.gridLayoutMedia : of(oneOnOne),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case "spotlight":
|
case "spotlight":
|
||||||
return this.spotlightExpanded.pipe(
|
return this.spotlightExpanded.pipe(
|
||||||
switchMap((expanded) =>
|
switchMap((expanded) =>
|
||||||
expanded
|
expanded
|
||||||
? this.spotlightExpandedLayout
|
? this.spotlightExpandedLayoutMedia
|
||||||
: this.spotlightLandscapeLayout,
|
: this.spotlightLandscapeLayoutMedia,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
case "narrow":
|
case "narrow":
|
||||||
return this.oneOnOneLayout.pipe(
|
return this.oneOnOneLayoutMedia.pipe(
|
||||||
switchMap((oneOnOne) =>
|
switchMap((oneOnOne) =>
|
||||||
oneOnOne === null
|
oneOnOne === null
|
||||||
? combineLatest(
|
? combineLatest(
|
||||||
@ -762,12 +761,12 @@ export class CallViewModel extends ViewModel {
|
|||||||
(grid, spotlight) =>
|
(grid, spotlight) =>
|
||||||
grid.length > smallMobileCallThreshold ||
|
grid.length > smallMobileCallThreshold ||
|
||||||
spotlight.some((vm) => vm instanceof ScreenShareViewModel)
|
spotlight.some((vm) => vm instanceof ScreenShareViewModel)
|
||||||
? this.spotlightPortraitLayout
|
? this.spotlightPortraitLayoutMedia
|
||||||
: this.gridLayout,
|
: this.gridLayoutMedia,
|
||||||
).pipe(switchAll())
|
).pipe(switchAll())
|
||||||
: // The expanded spotlight layout makes for a better one-on-one
|
: // The expanded spotlight layout makes for a better one-on-one
|
||||||
// experience in narrow windows
|
// experience in narrow windows
|
||||||
this.spotlightExpandedLayout,
|
this.spotlightExpandedLayoutMedia,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case "flat":
|
case "flat":
|
||||||
@ -777,14 +776,14 @@ export class CallViewModel extends ViewModel {
|
|||||||
case "grid":
|
case "grid":
|
||||||
// Yes, grid mode actually gets you a "spotlight" layout in
|
// Yes, grid mode actually gets you a "spotlight" layout in
|
||||||
// this window mode.
|
// this window mode.
|
||||||
return this.spotlightLandscapeLayout;
|
return this.spotlightLandscapeLayoutMedia;
|
||||||
case "spotlight":
|
case "spotlight":
|
||||||
return this.spotlightExpandedLayout;
|
return this.spotlightExpandedLayoutMedia;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
case "pip":
|
case "pip":
|
||||||
return this.pipLayout;
|
return this.pipLayoutMedia;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
this.scope.state(),
|
this.scope.state(),
|
||||||
|
Loading…
Reference in New Issue
Block a user