Fix spotlight layout

This commit is contained in:
Robin Townsend 2023-06-14 11:25:31 -04:00
parent 20c9c09258
commit 357e1f828a
2 changed files with 20 additions and 5 deletions

View file

@ -23,7 +23,12 @@ import {
} from "@livekit/components-react"; } from "@livekit/components-react";
import { usePreventScroll } from "@react-aria/overlays"; import { usePreventScroll } from "@react-aria/overlays";
import classNames from "classnames"; import classNames from "classnames";
import { Room, Track } from "livekit-client"; import {
LocalParticipant,
RemoteParticipant,
Room,
Track,
} from "livekit-client";
import { MatrixClient } from "matrix-js-sdk/src/client"; import { MatrixClient } from "matrix-js-sdk/src/client";
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall"; import { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
@ -473,11 +478,19 @@ function useParticipantTiles(
const items = useMemo(() => { const items = useMemo(() => {
const tiles: TileDescriptor<ItemData>[] = []; const tiles: TileDescriptor<ItemData>[] = [];
const screenshareExists = sfuParticipants.some(
(p) => p.isScreenShareEnabled
);
const participantsById = new Map<
string,
LocalParticipant | RemoteParticipant
>();
for (const p of sfuParticipants) participantsById.set(p.identity, p);
for (const [member, participantMap] of participants) { for (const [member, participantMap] of participants) {
for (const [deviceId] of participantMap) { for (const [deviceId] of participantMap) {
const id = `${member.userId}:${deviceId}`; const id = `${member.userId}:${deviceId}`;
const sfuParticipant = sfuParticipants.find((p) => p.identity === id); const sfuParticipant = participantsById.get(id);
// Skip rendering participants that did not connect to the SFU. // Skip rendering participants that did not connect to the SFU.
if (!sfuParticipant) { if (!sfuParticipant) {
@ -486,10 +499,13 @@ function useParticipantTiles(
const userMediaTile = { const userMediaTile = {
id, id,
focused: false, // Screenshare feeds take precedence for focus
focused:
!screenshareExists &&
sfuParticipant.isSpeaking &&
!sfuParticipant.isLocal,
local: sfuParticipant.isLocal, local: sfuParticipant.isLocal,
data: { data: {
id,
member, member,
sfuParticipant, sfuParticipant,
content: TileContent.UserMedia, content: TileContent.UserMedia,

View file

@ -32,7 +32,6 @@ import { ReactComponent as MicMutedIcon } from "../icons/MicMuted.svg";
import { useRoomMemberName } from "./useRoomMemberName"; import { useRoomMemberName } from "./useRoomMemberName";
export interface ItemData { export interface ItemData {
id: string;
member: RoomMember; member: RoomMember;
sfuParticipant: LocalParticipant | RemoteParticipant; sfuParticipant: LocalParticipant | RemoteParticipant;
content: TileContent; content: TileContent;