diff --git a/src/components/Nickname.js b/src/components/Nickname.js index e384e1e..94fe404 100644 --- a/src/components/Nickname.js +++ b/src/components/Nickname.js @@ -1,7 +1,11 @@ -import React from "react"; -import { Text } from "theme-ui"; +import React, { useState } from "react"; +import { Text, IconButton } from "theme-ui"; + +import Stream from "./Stream"; + +function Nickname({ nickname, stream }) { + const [streamMuted, setStreamMuted] = useState(false); -function Nickname({ nickname }) { return ( stream && setStreamMuted(!streamMuted)} > {nickname} + {stream && ( + + + {streamMuted ? ( + + ) : ( + + )} + + + )} + {stream && } ); } diff --git a/src/components/Party.js b/src/components/Party.js index 27a552f..20b10b0 100644 --- a/src/components/Party.js +++ b/src/components/Party.js @@ -3,7 +3,6 @@ import { Flex, Box, Text } from "theme-ui"; import AddPartyMemberButton from "./AddPartyMemberButton"; import Nickname from "./Nickname"; -import Stream from "./Stream"; import ChangeNicknameButton from "./ChangeNicknameButton"; import StartStreamButton from "./StartStreamButton"; @@ -45,16 +44,12 @@ function Party({ > {Object.entries(partyNicknames).map(([id, partyNickname]) => ( - + ))} - {(stream || Object.keys(partyStreams).length !== 0) && ( - Streams - )} - {stream && } - {partyStreams && - Object.entries(partyStreams).map(([id, partyStream]) => ( - - ))} diff --git a/src/components/Stream.js b/src/components/Stream.js index be7626e..95994c1 100644 --- a/src/components/Stream.js +++ b/src/components/Stream.js @@ -1,22 +1,14 @@ import React, { useRef, useEffect } from "react"; function Stream({ stream, muted }) { - const videoRef = useRef(); + const audioRef = useRef(); useEffect(() => { - if (videoRef.current) { - videoRef.current.srcObject = stream; + if (audioRef.current) { + audioRef.current.srcObject = stream; } }, [stream]); - return ( -