Underscoping

This commit is contained in:
Matthew Stratford 2021-01-30 19:24:32 +00:00
parent 337221cdd6
commit 2dae369d12

View file

@ -35,7 +35,12 @@ export function Timelord() {
return silence; return silence;
} }
const broadcastState = useSelector((state: RootState) => state.broadcast); const broadcastStage = useSelector(
(state: RootState) => state.broadcast.stage
);
const broadcastConnection = useSelector(
(state: RootState) => state.broadcast.connectionState
);
const [source, setSource] = useState({ id: -1, name: "Loading" }); const [source, setSource] = useState({ id: -1, name: "Loading" });
const [isSilence, setSilence] = useState(false); const [isSilence, setSilence] = useState(false);
@ -43,11 +48,11 @@ export function Timelord() {
async () => { async () => {
setSource(await getSource()); setSource(await getSource());
}, },
broadcastState.stage === "REGISTERED" ? 3000 : 10000 broadcastStage === "REGISTERED" ? 3000 : 10000
); );
useInterval(async () => { useInterval(async () => {
broadcastState.stage === "REGISTERED" broadcastStage === "REGISTERED"
? setSilence(await getSilence()) ? setSilence(await getSilence())
: setSilence(false); : setSilence(false);
}, 3000); }, 3000);
@ -70,8 +75,8 @@ export function Timelord() {
ticking={true} ticking={true}
timezone={"europe/london"} timezone={"europe/london"}
/> />
{broadcastState.stage === "REGISTERED" && {broadcastStage === "REGISTERED" &&
["LIVE", "CONNECTED"].indexOf(broadcastState.connectionState) === -1 ? ( ["LIVE", "CONNECTED"].indexOf(broadcastConnection) === -1 ? (
<span className="error">Streaming Error!</span> <span className="error">Streaming Error!</span>
) : isSilence ? ( ) : isSilence ? (
<span className="error">SILENCE DETECTED</span> <span className="error">SILENCE DETECTED</span>