Skip to content

Commit

Permalink
FCE-721 Fix toggle method (#142)
Browse files Browse the repository at this point in the history
## Description

Remove unnecessary `useMemo`

## Motivation and Context

There was a bug.

## Types of changes

Bug fix (non-breaking change which fixes an issue)
  • Loading branch information
kamil-stasiak authored Oct 16, 2024
1 parent 59ef1e1 commit 3430229
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/react-client/src/hooks/useTrackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export const useTrackManager = ({
const [currentTrackId, setCurrentTrackId] = useState<string | null>(null);
const [paused, setPaused] = useState<boolean>(false);

const peerStatus = useMemo(() => getCurrentPeerStatus(), [getCurrentPeerStatus]);

const currentTrack = useMemo(() => getRemoteOrLocalTrack(tsClient, currentTrackId), [tsClient, currentTrackId]);

async function setTrackMiddleware(middleware: TrackMiddleware | null): Promise<void> {
Expand Down Expand Up @@ -132,14 +130,14 @@ export const useTrackManager = ({
}, [mediaManager]);

const stream = useCallback(async () => {
if (peerStatus !== "connected") return;
if (getCurrentPeerStatus() !== "connected") return;

if (currentTrack?.trackId) {
await resumeStreaming();
} else {
await startStreaming();
}
}, [currentTrack, peerStatus, resumeStreaming, startStreaming]);
}, [currentTrack?.trackId, getCurrentPeerStatus, resumeStreaming, startStreaming]);

const toggle = useCallback(
async (mode: ToggleMode) => {
Expand Down

0 comments on commit 3430229

Please sign in to comment.