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/components/ConversationsOverviewCard.tsx b/client/src/components/ConversationsOverviewCard.tsx
index 67b4b68..b9dafc9 100644
--- a/client/src/components/ConversationsOverviewCard.tsx
+++ b/client/src/components/ConversationsOverviewCard.tsx
@@ -16,32 +16,14 @@
* <https://www.gnu.org/licenses/>.
*/
import { Card, CardActionArea, CardContent, CircularProgress, Typography } from '@mui/material';
-import { IConversation } from 'jami-web-common';
-import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router';
-import { useAuthContext } from '../contexts/AuthProvider';
+import { useConversationsSummariesQuery } from '../services/conversationQueries';
export default function ConversationsOverviewCard() {
- const { axiosInstance, account } = useAuthContext();
const navigate = useNavigate();
- const [conversationCount, setConversationCount] = useState<number | undefined>();
-
- const accountId = account.id;
-
- useEffect(() => {
- const controller = new AbortController();
- axiosInstance
- .get<IConversation[]>('/conversations', {
- signal: controller.signal,
- })
- .then(({ data }) => {
- console.log(data);
- setConversationCount(data.length);
- });
- return () => controller.abort(); // crash on React18
- }, [axiosInstance, accountId]);
+ const conversationSummariesQuery = useConversationsSummariesQuery();
return (
<Card onClick={() => navigate(`/`)}>
@@ -51,7 +33,7 @@
Conversations
</Typography>
<Typography gutterBottom variant="h5" component="h2">
- {conversationCount != null ? conversationCount : <CircularProgress size={24} />}
+ {conversationSummariesQuery?.data?.length ?? <CircularProgress size={24} />}
</Typography>
</CardContent>
</CardActionArea>