Skip to content

Commit

Permalink
fix: duplicate tiles in embed
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Sep 7, 2023
1 parent d2a05ac commit 70e5e3c
Showing 1 changed file with 1 addition and 11 deletions.
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

0 comments on commit 70e5e3c

Please sign in to comment.