bug where if someone totally quit or disconnected, need to remove them as well
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
ServerRequestChannels,
|
ServerRequestChannels,
|
||||||
ServerResponseChannels,
|
ServerResponseChannels,
|
||||||
SomeoneConnectedResponse,
|
SomeoneConnectedResponse,
|
||||||
|
SomeoneDisconnectedResponse,
|
||||||
SomeoneTunedResponse,
|
SomeoneTunedResponse,
|
||||||
SomeoneUntunedFromLineResponse,
|
SomeoneUntunedFromLineResponse,
|
||||||
TuneToLineRequest,
|
TuneToLineRequest,
|
||||||
@@ -134,6 +135,26 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
|
|||||||
);
|
);
|
||||||
}, [$ws, setConversationMap]);
|
}, [$ws, setConversationMap]);
|
||||||
|
|
||||||
|
// remove them from the line connected list and tuned list if they are there
|
||||||
|
$ws.on(
|
||||||
|
ServerResponseChannels.SOMEONE_DISCONNECTED_FROM_LINE,
|
||||||
|
(res: SomeoneDisconnectedResponse) => {
|
||||||
|
setConversationMap((draft) => {
|
||||||
|
if (!draft[res.lineId]) {
|
||||||
|
toast.error('there was a problem updating rooms!!!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
draft[res.lineId].connectedUserIds = draft[res.lineId].connectedUserIds?.filter(
|
||||||
|
(userId) => userId !== res.userId,
|
||||||
|
);
|
||||||
|
draft[res.lineId].tunedInUsers = draft[res.lineId].tunedInUsers?.filter(
|
||||||
|
(userId) => userId !== res.userId,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// add the conversation to the conversation map/client side cache
|
// add the conversation to the conversation map/client side cache
|
||||||
// has implications on realtime listening and also the ui on whether or not it's shown
|
// has implications on realtime listening and also the ui on whether or not it's shown
|
||||||
const handleAddConversationCache = useCallback(
|
const handleAddConversationCache = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user