Transform CallProvider into 'CallManager' hook, review WebSocket messages for calls
- These changes allowed to remove more cascading effects. It is now possible to reactivate StrictMode. Downside is we lost the 'optional context' of CallProvider: the call logic will be loaded even if there is no call.
- The WebSocket messages have been changed so the client does not have to know the conversation members before a call. Previously, the client had to fetch the conversation members for a call, which was causing cascading effects.
- Accidentally, moving the handling of conversation members to the server added some logic for calls with more than two participants, but it is still not ready to work.
* CallProvider.tsx will be renamed in next commit in order to make it easier to track its file history
Change-Id: Iae711009adafce065ac3defc1c91c7ca0f37898c
diff --git a/client/src/pages/CallInterface.tsx b/client/src/pages/CallInterface.tsx
index f66a180..2892bb7 100644
--- a/client/src/pages/CallInterface.tsx
+++ b/client/src/pages/CallInterface.tsx
@@ -48,7 +48,8 @@
import CallChatDrawer from '../components/CallChatDrawer';
import VideoOverlay from '../components/VideoOverlay';
import VideoStream from '../components/VideoStream';
-import { CallStatus, useCallContext, VideoStatus } from '../contexts/CallProvider';
+import { useCallManagerContext } from '../contexts/CallManagerProvider';
+import { CallStatus, VideoStatus } from '../contexts/CallProvider';
import { useConversationContext } from '../contexts/ConversationProvider';
import { useUserMediaContext } from '../contexts/UserMediaProvider';
import { formatCallDuration } from '../utils/dates×';
@@ -57,7 +58,7 @@
import CallPermissionDenied from './CallPermissionDenied';
export default () => {
- const { callStatus, isChatShown, isFullscreen } = useCallContext();
+ const { callStatus, isChatShown, isFullscreen } = useCallManagerContext();
const callInterfaceRef = useRef<HTMLDivElement>();
useEffect(() => {
@@ -99,7 +100,7 @@
audiooutput: { id: audioOutDeviceId },
},
} = useUserMediaContext();
- const { remoteStreams, videoStatus } = useCallContext();
+ const { remoteStreams, videoStatus } = useCallManagerContext();
const remoteVideoRef = useRef<VideoElementWithSinkId | null>(null);
const gridItemRef = useRef<HTMLDivElement | null>(null);
const [isLocalVideoZoomed, setIsLocalVideoZoomed] = useState(false);
@@ -156,7 +157,7 @@
};
const CallInterfaceInformation = () => {
- const { callStartTime } = useCallContext();
+ const { callStartTime } = useCallManagerContext();
const { conversationDisplayName } = useConversationContext();
const [elapsedTime, setElapsedTime] = useState<Duration>(
dayjs.duration(callStartTime ? Date.now() - callStartTime : 0)