Skip to content

Commit

Permalink
feat: added loader to production-line-view
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 committed Apr 9, 2024
1 parent 8633f0e commit 9772ee6
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/components/production-line/production-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useAudioElement } from "./use-audio-element.ts";
import { UserList } from "./user-list.tsx";
import { API } from "../../api/api.ts";
import { noop } from "../../helpers.ts";
import { Loader } from "../loader/loader.tsx";

const TempDiv = styled.div`
padding: 1rem;
Expand All @@ -22,6 +23,7 @@ export const ProductionLine: FC = () => {
const [participants, setParticipants] = useState<
{ name: string; sessionid: string }[] | null
>(null);
const [loading, setLoading] = useState<boolean>(false);

const { playbackState, audioElement } = useAudioElement({
audioContainerRef,
Expand Down Expand Up @@ -68,7 +70,12 @@ export const ProductionLine: FC = () => {
}
}, [navigate, joinProductionOptions]);

// TODO pretty spinner component
useEffect(() => {
setLoading(true);
if (connectionState === "connected") {
setLoading(false);
}
}, [connectionState]);

// TODO if (!input !output !username) return <JoinProductionForm />

Expand All @@ -84,21 +91,27 @@ export const ProductionLine: FC = () => {
// Mute/Unmute speaker
// Show active sink and mic
// Exit button (link to /, clear production from state)

return (
<div>
<TempDiv>
<ActionButton onClick={exit}>Exit</ActionButton>
</TempDiv>
<TempDiv>Production View</TempDiv>
<TempDiv ref={audioContainerRef} />
{playbackState && (
<TempDiv>Audio Playback State: {playbackState}</TempDiv>
{loading && <Loader className="join-production" />}
{!loading && (
<>
<TempDiv>Production View</TempDiv>
<TempDiv ref={audioContainerRef} />
{playbackState && (
<TempDiv>Audio Playback State: {playbackState}</TempDiv>
)}
{connectionState && (
<TempDiv>RTC Connection State: {connectionState}</TempDiv>
)}

<UserList participants={participants} />
</>
)}
{connectionState && (
<TempDiv>RTC Connection State: {connectionState}</TempDiv>
)}

<UserList participants={participants} />
</div>
);
};
Expand Down

0 comments on commit 9772ee6

Please sign in to comment.