Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: duplicate tiles in embed #1863

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions packages/roomkit-react/src/Prebuilt/layouts/EmbedView.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import {
selectLocalPeerID,
selectLocalPeerRoleName,
selectPeers,
selectPeerScreenSharing,
throwErrorHandler,
Expand All @@ -25,21 +23,13 @@ export const EmbedView = () => {
export const EmbebScreenShareView = ({ children }) => {
const peers = useHMSStore(selectPeers);

const localPeerID = useHMSStore(selectLocalPeerID);
const localPeerRole = useHMSStore(selectLocalPeerRoleName);
const peerPresenting = useHMSStore(selectPeerScreenSharing);
const isPresenterFromMyRole = peerPresenting?.roleName?.toLowerCase() === localPeerRole?.toLowerCase();
const amIPresenting = localPeerID === peerPresenting?.id;
const showPresenterInSmallTile = amIPresenting || isPresenterFromMyRole;
const [, setActiveScreenSharePeer] = useSetAppDataByKey(APP_DATA.activeScreensharePeerId);

const smallTilePeers = useMemo(() => {
const smallTilePeers = peers.filter(peer => peer.id !== peerPresenting?.id);
if (showPresenterInSmallTile && peerPresenting) {
smallTilePeers.unshift(peerPresenting); // put presenter on first page
}
return smallTilePeers;
}, [peers, peerPresenting, showPresenterInSmallTile]);
}, [peers, peerPresenting]);

useEffect(() => {
setActiveScreenSharePeer(peerPresenting?.id);
Expand Down
Loading