removed deep memos

This commit is contained in:
Jon 2021-07-06 12:47:22 +01:00
parent 7d47291016
commit 0ad5553050
3 changed files with 7 additions and 15 deletions

View File

@ -13,7 +13,7 @@ export const Header = () => {
<div className="capsule">Basic call demo</div> <div className="capsule">Basic call demo</div>
<div className="capsule"> <div className="capsule">
{`${participantCount} ${ {`${participantCount} ${
participantCount > 1 ? 'participants' : 'participant' participantCount === 1 ? 'participant' : 'participants'
}`} }`}
</div> </div>
{customCapsule && ( {customCapsule && (

View File

@ -8,7 +8,6 @@ import React, {
useMemo, useMemo,
} from 'react'; } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { useDeepCompareMemo } from 'use-deep-compare';
import { sortByKey } from '../lib/sortByKey'; import { sortByKey } from '../lib/sortByKey';
@ -45,16 +44,13 @@ export const ParticipantsProvider = ({ children }) => {
/** /**
* Only return participants that should be visible in the call * Only return participants that should be visible in the call
*/ */
const participants = useDeepCompareMemo( const participants = useMemo(() => state.participants, [state.participants]);
() => allParticipants.filter((p) => p?.isOwner),
[allParticipants]
);
/** /**
* The number of participants, who are not a shared screen * The number of participants, who are not a shared screen
* (technically a shared screen counts as a participant, but we shouldn't tell humans) * (technically a shared screen counts as a participant, but we shouldn't tell humans)
*/ */
const participantCount = useDeepCompareMemo( const participantCount = useMemo(
() => participants.filter(({ isScreenshare }) => !isScreenshare).length, () => participants.filter(({ isScreenshare }) => !isScreenshare).length,
[participants] [participants]
); );
@ -62,7 +58,7 @@ export const ParticipantsProvider = ({ children }) => {
/** /**
* The participant who most recently got mentioned via a `active-speaker-change` event * The participant who most recently got mentioned via a `active-speaker-change` event
*/ */
const activeParticipant = useDeepCompareMemo( const activeParticipant = useMemo(
() => participants.find(({ isActiveSpeaker }) => isActiveSpeaker), () => participants.find(({ isActiveSpeaker }) => isActiveSpeaker),
[participants] [participants]
); );
@ -70,7 +66,7 @@ export const ParticipantsProvider = ({ children }) => {
/** /**
* The local participant * The local participant
*/ */
const localParticipant = useDeepCompareMemo( const localParticipant = useMemo(
() => () =>
allParticipants.find( allParticipants.find(
({ isLocal, isScreenshare }) => isLocal && !isScreenshare ({ isLocal, isScreenshare }) => isLocal && !isScreenshare
@ -78,10 +74,7 @@ export const ParticipantsProvider = ({ children }) => {
[allParticipants] [allParticipants]
); );
const isOwner = useDeepCompareMemo( const isOwner = useMemo(() => localParticipant?.isOwner, [localParticipant]);
() => localParticipant?.isOwner,
[localParticipant]
);
/** /**
* The participant who should be rendered prominently right now * The participant who should be rendered prominently right now
@ -119,7 +112,7 @@ export const ParticipantsProvider = ({ children }) => {
/** /**
* Screen shares * Screen shares
*/ */
const screens = useDeepCompareMemo( const screens = useMemo(
() => allParticipants.filter(({ isScreenshare }) => isScreenshare), () => allParticipants.filter(({ isScreenshare }) => isScreenshare),
[allParticipants] [allParticipants]
); );

View File

@ -186,7 +186,6 @@ export const TracksProvider = ({ children }) => {
}; };
const trackStoppedBatchInterval = setInterval(() => { const trackStoppedBatchInterval = setInterval(() => {
console.log(trackStoppedQueue);
if (!trackStoppedQueue.length) { if (!trackStoppedQueue.length) {
return; return;
} }