From 0aeb34e40760556738198f7269c48a4c6d53ae60 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 19 Jun 2022 09:21:13 -0500 Subject: [PATCH] nice state which would be per peer connection or call --- .../desktop/src/providers/ConversationProvider.tsx | 13 +++++++++---- packages/desktop/src/util/types.ts | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/desktop/src/providers/ConversationProvider.tsx b/packages/desktop/src/providers/ConversationProvider.tsx index 276b64a..e081184 100644 --- a/packages/desktop/src/providers/ConversationProvider.tsx +++ b/packages/desktop/src/providers/ConversationProvider.tsx @@ -481,18 +481,18 @@ function Room({ if (draft[conversation._id.toString()]) { draft[conversation._id.toString()].room = { ...(draft[conversation._id.toString()].room ?? {}), - otherUserId: { peer: localPeerConnection }, + otherUserId: { peer: localPeerConnection, isConnecting: true }, }; } - draft[conversation._id.toString()].isConnectingToRoom = true; }); }); localPeerConnection.on('stream', (remoteStream: MediaStream) => { // globally updating conversation so that other views can render what they want + toast.success('got stream from remote, going to add to our '); + setConversationMap((draft) => { if (draft[conversation._id.toString()].room[otherUserId]) { - toast.success('got stream from remote, going to add to our '); draft[conversation._id.toString()].room[otherUserId].stream = remoteStream; remoteStream.getTracks().forEach((track) => { // TODO: add particular track to right place @@ -503,6 +503,11 @@ function Room({ localPeerConnection.on('connect', () => { toast.success('successfully connected to another peer'); + setConversationMap((draft) => { + if (draft[conversation._id.toString()].room[otherUserId]) { + draft[conversation._id.toString()].room[otherUserId].isConnecting = false; + } + }); }); localPeerConnection.on('track', (track, stream) => { @@ -515,7 +520,7 @@ 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 remove + // TODO: update the map to remove the user and all contribution contens toast.error('peer connection was closed'); }); diff --git a/packages/desktop/src/util/types.ts b/packages/desktop/src/util/types.ts index 41eeeb1..a6500ea 100644 --- a/packages/desktop/src/util/types.ts +++ b/packages/desktop/src/util/types.ts @@ -19,9 +19,11 @@ export type MasterConversation = Conversation & { audioTrack?: MediaStreamTrack; videoTrack?: MediaStreamTrack; screenTrack?: MediaStreamTrack; + + // calling happening whether it is a newbie or master + isConnecting?: boolean; }; }; - isConnectingToRoom?: boolean; // all of audio clips, links, media, etc. content?: ContentBlock[];