Add conversation requests list
- Add routes to REST API for conversation requests
- Add websocket notification on new conversation requests. This is unreliable.
- Rename 'ColoredCallButton' as 'ColoredRoundButton' and move it to Buttons file for reuse
- Review logic to show conversation tabs
- Add useConversationDisplayNameShort for conversations' names in lists. Will need more work.
- Add hooks to help managing React Query's cache
- Use React Query to remove conversations and update the cache doing so.
- Add ContactService and ConversationService as a way to group reusable functions for the server. This is inspired by jami-android
Known bug: The server often freezes on getContactFromUri (in ContactService) when a new conversation request is received.
Change-Id: I46a60a401f09c3941c864afcdb2625b5fcfe054a
diff --git a/client/src/hooks/useConversationDisplayName.ts b/client/src/hooks/useConversationDisplayName.ts
index 3949c45..f64012e 100644
--- a/client/src/hooks/useConversationDisplayName.ts
+++ b/client/src/hooks/useConversationDisplayName.ts
@@ -55,3 +55,29 @@
return translateEnumeration<ConversationMember>(members, options);
}, [account, adminTitle, members, t]);
};
+
+export const useConversationDisplayNameShort = (
+ account: Account | null,
+ title: string | undefined,
+ membersNames: string[]
+): string => {
+ return useMemo(() => {
+ if (title) {
+ return title;
+ }
+
+ if (membersNames.length === 0) {
+ return account?.getDisplayName() || '';
+ }
+
+ const twoFirstMembers = membersNames.slice(0, 2);
+ const baseName = twoFirstMembers.join(', ');
+ const excess = membersNames.length - twoFirstMembers.length;
+
+ if (excess > 0) {
+ return baseName + ' +' + excess;
+ } else {
+ return baseName;
+ }
+ }, [account, title, membersNames]);
+};