rendering once only for the tuned in lines once I am tuned in

This commit is contained in:
talksik
2022-05-18 20:34:33 -05:00
parent 17b27afce6
commit 97c0b29480
2 changed files with 2 additions and 17 deletions
@@ -73,7 +73,7 @@ export function StreamProvider({ children }: { children: React.ReactChild }) {
<StreamProviderContext.Provider value={{ peerMap, userLocalStream }}> <StreamProviderContext.Provider value={{ peerMap, userLocalStream }}>
{/* handles stream connections */} {/* handles stream connections */}
{Object.values(roomsMap).map((line) => { {Object.values(roomsMap).map((line) => {
if (line.tunedInMemberIds.includes(user._id.toString())) if (line.tunedInMemberIds?.includes(user._id.toString()))
return ( return (
<MemoLineConnector <MemoLineConnector
key={`streamConnector-${line.lineDetails._id.toString()}`} key={`streamConnector-${line.lineDetails._id.toString()}`}
@@ -81,8 +81,6 @@ export function StreamProvider({ children }: { children: React.ReactChild }) {
line={line} line={line}
/> />
); );
console.log(line.tunedInMemberIds);
})} })}
{children} {children}
@@ -104,7 +102,6 @@ function LineConnector({
handleAddPeer: (userId: string, peerObj: Peer) => void; handleAddPeer: (userId: string, peerObj: Peer) => void;
}) { }) {
console.log('rendering this piece of shit'); console.log('rendering this piece of shit');
console.log(line);
useEffectOnce(() => { useEffectOnce(() => {
console.log('got initial list for this channel that I am tuned into'); console.log('got initial list for this channel that I am tuned into');
@@ -112,13 +109,7 @@ function LineConnector({
console.log(line.tunedInMemberIds); console.log(line.tunedInMemberIds);
}); });
return ( return <></>;
<>
{line.tunedInMemberIds.map((userId) => (
<StreamConnector key={userId} peerUserId={userId} handleAddPeer={handleAddPeer} />
))}
</>
);
} }
function StreamConnector({ function StreamConnector({
@@ -134,10 +125,6 @@ function StreamConnector({
useEffect(() => { useEffect(() => {
console.log('calling all of the initials until this component unmounts'); console.log('calling all of the initials until this component unmounts');
setInterval(() => {
console.log('still have this mediadevice in memory!');
});
navigator.mediaDevices navigator.mediaDevices
.getUserMedia({ video: false, audio: true }) .getUserMedia({ video: false, audio: true })
.then((localMediaStream: MediaStream) => { .then((localMediaStream: MediaStream) => {
@@ -6,8 +6,6 @@ import { AuthProvider } from '../providers/AuthProvider';
import { ElectronProvider } from '../providers/ElectronProvider'; import { ElectronProvider } from '../providers/ElectronProvider';
import { SocketProvider } from '../providers/SocketProvider'; import { SocketProvider } from '../providers/SocketProvider';
import ProtectedRoute from './protected/ProtectedRoute'; import ProtectedRoute from './protected/ProtectedRoute';
import { StreamProvider } from '../providers/StreamProvider';
export default function ElectronApp() { export default function ElectronApp() {
return ( return (
<ElectronProvider> <ElectronProvider>