Remove non-null assertion in ConversationProvider
- Add `createOptionalContext` that is used by `AuthContext` and `ConversationContext` to create a context with a hook
that can be used to retrieve its value and throw an error if it's undefined.
- In `router.tsx`, put `Messenger` inside `ConversationProvider`.
- In `ConversationListItem`, use the conversationId from the `ConversationContext ` instead of the url params.
- Fix bug in `CallInterface` with fullscreen.
- Remove unecessary useEffect dependency in `NotificationManager`.
Change-Id: Ib5f0ae6a0a34cdbdb02f871e36194376d945230d
diff --git a/client/src/contexts/CallProvider.tsx b/client/src/contexts/CallProvider.tsx
index 13e0d24..39aad07 100644
--- a/client/src/contexts/CallProvider.tsx
+++ b/client/src/contexts/CallProvider.tsx
@@ -25,7 +25,7 @@
import { CallRouteParams } from '../router';
import { callTimeoutMs } from '../utils/constants';
import { SetState, WithChildren } from '../utils/utils';
-import { ConversationContext } from './ConversationProvider';
+import { useConversationContext } from './ConversationProvider';
import { MediaDevicesInfo, MediaInputKind, WebRtcContext } from './WebRtcProvider';
import { IWebSocketContext, WebSocketContext } from './WebSocketProvider';
@@ -124,7 +124,7 @@
const { state: routeState } = useUrlParams<CallRouteParams>();
const { localStream, sendWebRtcOffer, iceConnectionState, closeConnection, getMediaDevices, updateLocalStream } =
useContext(WebRtcContext);
- const { conversationId, conversation } = useContext(ConversationContext);
+ const { conversationId, conversation } = useConversationContext();
const navigate = useNavigate();
const [mediaDevices, setMediaDevices] = useState(defaultCallContext.mediaDevices);