From e6901eb04c5dab93278fc9c86afeab969824fd6e Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 7 Jan 2023 18:56:01 +0000 Subject: [PATCH] Add related chats to group profile --- src/renderer/components/dialogs/ViewGroup.tsx | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx index 4a87c83aa4..37939cc83e 100644 --- a/src/renderer/components/dialogs/ViewGroup.tsx +++ b/src/renderer/components/dialogs/ViewGroup.tsx @@ -6,9 +6,13 @@ import { DeltaDialogBody, DeltaDialogOkCancelFooter, } from './DeltaDialog' +import ChatListItem from '../chat/ChatListItem' import { useContactSearch, AddMemberInnerDialog } from './CreateChat' import { QrCodeShowQrInner } from './QrCode' +import { selectChat } from '../helpers/ChatMethods' +import { useThemeCssVar } from '../../ThemeManager' import { ContactList2, useContactsMap } from '../contact/ContactList' +import { useLogicVirtualChatList, ChatListPart } from '../chat/ChatList' import { PseudoListItemShowQrCode, PseudoListItemAddMember, @@ -136,6 +140,17 @@ function ViewGroupInner(props: { const { onClose, chat, isBroadcast } = props const tx = useTranslationFunction() + const [chatListIds, setChatListIds] = useState<[number, number][]>([]) + + useEffect(() => { + BackendRemote.rpc + .getSimilarChatlistEntries(selectedAccountId(), chat.id) + .then(setChatListIds) + }, [chat.id]) + + const { isChatLoaded, loadChats, chatCache } = + useLogicVirtualChatList(chatListIds) + const chatDisabled = !chat.canSend const { @@ -207,6 +222,14 @@ function ViewGroupInner(props: { null ) + const onChatClick = (chatId: number) => { + selectChat(chatId) + onClose() + } + + const CHATLISTITEM_CHAT_HEIGHT = + Number(useThemeCssVar('--SPECIAL-chatlist-item-chat-height')) || 64 + return ( <> {!profileContact && ( @@ -238,6 +261,32 @@ function ViewGroupInner(props: { {groupName} {chat.isProtected && }

+
+ {tx('profile_shared_chats')} +
+
+ 'key' + chatListIds[index]} + itemHeight={CHATLISTITEM_CHAT_HEIGHT} + > + {({ index, style }) => { + const [chatId] = chatListIds[index] + return ( +
+ +
+ ) + }} +
+
{!isBroadcast ? tx(