untuning with escape...which should then remove from tunedids list and thus the source of truth whether or not to render the peer connector and rtc stuff
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
StartBroadcastingRequest,
|
||||
StopBroadcastingRequest,
|
||||
TuneToLineRequest,
|
||||
UntuneFromLineRequest,
|
||||
UserStartedBroadcastingResponse,
|
||||
UserStoppedBroadcastingResponse,
|
||||
} from "@nirvana/core/sockets/channels";
|
||||
@@ -257,6 +258,20 @@ function useSocketHandler(linesData: MasterLineData[]) {
|
||||
[$ws]
|
||||
);
|
||||
|
||||
const handleUnTuneToLine = useCallback(
|
||||
(lineId: string) => {
|
||||
// they already are in the socket room for updates including media connections and disconnections
|
||||
// but set the flag so that the line row can know whether or not to start the webrtc process
|
||||
// and know when to get out or disconnect from the webrtc when the flag turns off
|
||||
|
||||
$ws.emit(
|
||||
ServerRequestChannels.UNTUNE_FROM_LINE,
|
||||
new UntuneFromLineRequest(lineId)
|
||||
);
|
||||
},
|
||||
[$ws]
|
||||
);
|
||||
|
||||
/**
|
||||
* This is when the user wants to tell everyone that they are streaming/broadcasting/buzzing to
|
||||
* a specific line, whether they are toggle tuned or temporarily tuned in
|
||||
@@ -313,6 +328,7 @@ function useSocketHandler(linesData: MasterLineData[]) {
|
||||
handleStartBroadcast,
|
||||
handleStopBroadcast,
|
||||
handleFetchMoreAudioBlocks,
|
||||
handleUnTuneToLine,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ export default function NirvanaTerminal() {
|
||||
// simply using this query for specific data on loading
|
||||
// todo: add these properties in context provider value although more work down the line for control
|
||||
const { isLoading: isLoadingInitialLines } = useUserLines();
|
||||
const { linesMap, handleTuneToLine } = useLineDataProvider();
|
||||
const { linesMap, handleTuneToLine, handleUnTuneToLine } =
|
||||
useLineDataProvider();
|
||||
|
||||
useEffect(() => {
|
||||
console.log("change/update in lines map");
|
||||
@@ -56,8 +57,17 @@ export default function NirvanaTerminal() {
|
||||
const handleEscape = useCallback(() => {
|
||||
console.log("deselecting line");
|
||||
|
||||
setSelectedLineId(null);
|
||||
}, [setSelectedLineId]);
|
||||
setSelectedLineId((prevSelectedLineId) => {
|
||||
// ! only want to untune if it's a temporarily tuned line
|
||||
if (
|
||||
linesMap[prevSelectedLineId].currentUserMember?.state ===
|
||||
LineMemberState.INBOX
|
||||
)
|
||||
handleUnTuneToLine(prevSelectedLineId);
|
||||
|
||||
return null;
|
||||
});
|
||||
}, [setSelectedLineId, linesMap]);
|
||||
|
||||
const handleStartBroadcast = useCallback(
|
||||
(lineId: string) => () => {
|
||||
|
||||
Reference in New Issue
Block a user