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/components/CallChatDrawer.tsx b/client/src/components/CallChatDrawer.tsx
index d2040d7..ef5cf04 100644
--- a/client/src/components/CallChatDrawer.tsx
+++ b/client/src/components/CallChatDrawer.tsx
@@ -19,7 +19,7 @@
import { useContext } from 'react';
import { CallContext } from '../contexts/CallProvider';
-import { ConversationContext } from '../contexts/ConversationProvider';
+import { useConversationContext } from '../contexts/ConversationProvider';
import ChatInterface from '../pages/ChatInterface';
import { CloseButton } from './Button';
@@ -45,7 +45,7 @@
const CallChatDrawerHeader = () => {
const { setIsChatShown } = useContext(CallContext);
- const { conversation } = useContext(ConversationContext);
+ const { conversation } = useConversationContext();
// TODO: Improve this to support multiple members
const contact = conversation.getFirstMember().contact;