handling starting and stopping broadcast

This commit is contained in:
talksik
2022-05-06 12:06:16 -05:00
parent 886f10cf23
commit 309e74ff94
2 changed files with 34 additions and 7 deletions
+32 -6
View File
@@ -53,14 +53,39 @@ export default function NirvanaTerminal() {
setSelectedLineId(null);
}, [setSelectedLineId]);
const handleStartBroadcast = useCallback(() => {
if (selectedLineId) handleUserBroadcast(selectedLineId, true);
}, [selectedLineId]);
const handleStartBroadcast = useCallback(
(lineId: string) => () => {
console.log(`starting broadcast for ${lineId}!!!`);
// todo: enable stream in this tuned in channel
if (lineId) handleUserBroadcast(lineId, true);
},
[]
);
const handleStopBroadcast = useCallback(
(lineId: string) => () => {
console.log(`stopping broadcast for ${lineId}!!!`);
// todo: disable stream in this tuned in channel
if (lineId) handleUserBroadcast(lineId, false);
},
[]
);
const keyMap: KeyMap = useMemo(
() => ({
DESELECT_LINE: "esc",
START_BROADCAST: "`",
START_BROADCAST: {
sequence: "`",
action: "keydown",
},
STOP_BROADCAST: {
sequence: "`",
action: "keyup",
},
}),
[]
);
@@ -68,9 +93,10 @@ export default function NirvanaTerminal() {
const handlers = useMemo(
() => ({
DESELECT_LINE: handleEscape,
START_BROADCAST: handleStartBroadcast,
START_BROADCAST: handleStartBroadcast(selectedLineId),
STOP_BROADCAST: handleStopBroadcast(selectedLineId),
}),
[handleEscape, handleStartBroadcast]
[selectedLineId]
);
return (