From dbba1deb5ec6ed778a27c43906f31f649e364883 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 | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx
index 4a87c83aa4..9e63d22750 100644
--- a/src/renderer/components/dialogs/ViewGroup.tsx
+++ b/src/renderer/components/dialogs/ViewGroup.tsx
@@ -6,9 +6,14 @@ import {
DeltaDialogBody,
DeltaDialogOkCancelFooter,
} from './DeltaDialog'
+import ChatListItem from '../chat/ChatListItem'
import { useContactSearch, AddMemberInnerDialog } from './CreateChat'
+import { useChatList } from '../chat/ChatListHelpers'
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 +141,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)
+ }, [])
+
+ const { isChatLoaded, loadChats, chatCache } =
+ useLogicVirtualChatList(chatListIds)
+
const chatDisabled = !chat.canSend
const {
@@ -207,6 +223,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 +262,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(