From ce717a56f55eaa8c357f24985dec9309a28137ef Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 19 Jun 2022 11:24:22 -0500 Subject: [PATCH] adding potential code for managing closed connections --- .../desktop/src/providers/ConversationProvider.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/providers/ConversationProvider.tsx b/packages/desktop/src/providers/ConversationProvider.tsx index 207fa46..9e02518 100644 --- a/packages/desktop/src/providers/ConversationProvider.tsx +++ b/packages/desktop/src/providers/ConversationProvider.tsx @@ -534,7 +534,12 @@ function Room({ // the person will be removed from the tuned in list, but the connections here are decoupled from that flow // we want to manage the room within the master conversation and remove it for ourselves - // TODO: update the map to remove the user and all contribution contens + setConversationMap((draft) => { + if (draft[conversation._id.toString()].room[otherUserId]) { + draft[conversation._id.toString()].room[otherUserId].peer?.destroy(); + delete draft[conversation._id.toString()].room[otherUserId]; + } + }); toast.error('peer connection was closed'); }); @@ -625,7 +630,12 @@ function Room({ // the person will be removed from the tuned in list, but the connections here are decoupled from that flow // we want to manage the room within the master conversation and remove it for ourselves - // TODO: update the map to remove the user and all contribution contens + setConversationMap((draft) => { + if (draft[conversation._id.toString()].room[res.userWhoCalled]) { + draft[conversation._id.toString()].room[res.userWhoCalled].peer?.destroy(); + delete draft[conversation._id.toString()].room[res.userWhoCalled]; + } + }); toast.error('peer connection was closed'); });