Divide Conversation into ConversationInfos, ConversationMember, and ConversationSummary
- ConversationSummary is used to display ConversationList.
- Having the three separated will help managing queries.
- Adding ConversationSummary required to solve some inconsistencies in ConversationList, which was mixing contacts and conversations. ContactSearchResultList has been added as a quick fix . It will need more work.
- Some tools to uniformize conversation names have been introduced. They will need more work.
Note the diplaying of ConversationList is left broken in this commit.
Change-Id: I29337906cc43781a9c4790735490a6ee2cc51cb0
diff --git a/client/src/contexts/WebRtcProvider.tsx b/client/src/contexts/WebRtcProvider.tsx
index 55a3a1d..e35df0c 100644
--- a/client/src/contexts/WebRtcProvider.tsx
+++ b/client/src/contexts/WebRtcProvider.tsx
@@ -20,7 +20,7 @@
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { createOptionalContext } from '../hooks/createOptionalContext';
-import { Conversation } from '../models/conversation';
+import { ConversationMember } from '../models/conversation-member';
import { WithChildren } from '../utils/utils';
import { useAuthContext } from './AuthProvider';
import { CallManagerContext } from './CallManagerProvider';
@@ -52,7 +52,7 @@
const { account } = useAuthContext();
const [webRtcConnection, setWebRtcConnection] = useState<RTCPeerConnection | undefined>();
const webSocket = useContext(WebSocketContext);
- const { callConversation, callData } = useContext(CallManagerContext);
+ const { callConversationInfos, callMembers, callData } = useContext(CallManagerContext);
useEffect(() => {
if (webRtcConnection && !callData) {
@@ -85,10 +85,11 @@
() => ({
webRtcConnection,
webSocket,
- conversation: callConversation,
+ conversationInfos: callConversationInfos,
+ members: callMembers,
conversationId: callData?.conversationId,
}),
- [webRtcConnection, webSocket, callConversation, callData?.conversationId]
+ [webRtcConnection, webSocket, callConversationInfos, callMembers, callData?.conversationId]
);
return (
@@ -104,14 +105,14 @@
};
const useWebRtcContextValue = ({
- conversation,
+ members,
conversationId,
webRtcConnection,
webSocket,
}: {
webRtcConnection: RTCPeerConnection;
webSocket: IWebSocketContext;
- conversation: Conversation;
+ members: ConversationMember[];
conversationId: string;
}) => {
const [localStream, setLocalStream] = useState<MediaStream>();
@@ -133,7 +134,7 @@
const [iceCandidateQueue, setIceCandidateQueue] = useState<RTCIceCandidate[]>([]);
// TODO: This logic will have to change to support multiple people in a call
- const contactUri = useMemo(() => conversation.getFirstMember().contact.uri, [conversation]);
+ const contactUri = useMemo(() => members[0]?.contact.uri, [members]);
const getMediaDevices = useCallback(async (): Promise<MediaDevicesInfo> => {
try {