Improve readability
This commit is contained in:
@@ -425,20 +425,17 @@ export class CallViewModel extends ViewModel {
|
|||||||
scan<(readonly [UserMedia, boolean])[], UserMedia, null>(
|
scan<(readonly [UserMedia, boolean])[], UserMedia, null>(
|
||||||
(prev, mediaItems) => {
|
(prev, mediaItems) => {
|
||||||
// Only remote users that are still in the call should be sticky
|
// Only remote users that are still in the call should be sticky
|
||||||
const stickyPrev =
|
const [stickyMedia, stickySpeaking] =
|
||||||
prev === null || prev.vm.local
|
(!prev?.vm.local && mediaItems.find(([m]) => m === prev)) || [];
|
||||||
? null
|
|
||||||
: mediaItems.find(([m]) => m === prev);
|
|
||||||
const stillSpeaking = stickyPrev?.[1];
|
|
||||||
// Decide who to spotlight:
|
// Decide who to spotlight:
|
||||||
// If the previous speaker is still speaking, stick with them rather
|
// If the previous speaker is still speaking, stick with them rather
|
||||||
// than switching eagerly to someone else
|
// than switching eagerly to someone else
|
||||||
return stillSpeaking
|
return stickySpeaking
|
||||||
? stickyPrev[0]
|
? stickyMedia!
|
||||||
: // Otherwise, select any remote user who is speaking
|
: // Otherwise, select any remote user who is speaking
|
||||||
(mediaItems.find(([m, s]) => !m.vm.local && s)?.[0] ??
|
(mediaItems.find(([m, s]) => !m.vm.local && s)?.[0] ??
|
||||||
// Otherwise, stick with the person who was last speaking
|
// Otherwise, stick with the person who was last speaking
|
||||||
stickyPrev?.[0] ??
|
stickyMedia ??
|
||||||
// Otherwise, spotlight an arbitrary remote user
|
// Otherwise, spotlight an arbitrary remote user
|
||||||
mediaItems.find(([m]) => !m.vm.local)?.[0] ??
|
mediaItems.find(([m]) => !m.vm.local)?.[0] ??
|
||||||
// Otherwise, spotlight the local user
|
// Otherwise, spotlight the local user
|
||||||
|
|||||||
Reference in New Issue
Block a user