smooth untuning and listening to that event as well as firing well, although could need more involvement than this simplicity

This commit is contained in:
talksik
2022-06-11 18:27:22 -05:00
parent 302cb6c929
commit 216e21cb4f
@@ -4,6 +4,7 @@ import {
ServerResponseChannels, ServerResponseChannels,
SomeoneConnectedResponse, SomeoneConnectedResponse,
SomeoneTunedResponse, SomeoneTunedResponse,
SomeoneUntunedFromLineResponse,
TuneToLineRequest, TuneToLineRequest,
UntuneFromLineRequest, UntuneFromLineRequest,
} from '@nirvana/core/sockets/channels'; } from '@nirvana/core/sockets/channels';
@@ -102,6 +103,22 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
draft[res.lineId].tunedInUsers = res.allUsers; draft[res.lineId].tunedInUsers = res.allUsers;
}); });
}); });
$ws.on(
ServerResponseChannels.SOMEONE_UNTUNED_FROM_LINE,
(res: SomeoneUntunedFromLineResponse) => {
setConversationMap((draft) => {
if (!draft[res.lineId]) {
toast.error('no line');
return;
}
draft[res.lineId].tunedInUsers = draft[res.lineId].tunedInUsers.filter(
(userId) => userId !== res.userId,
);
});
},
);
}, [$ws, setConversationMap]); }, [$ws, setConversationMap]);
useEffect(() => { useEffect(() => {