Skip to content

Commit

Permalink
Add related chats to group profile
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Sep 7, 2023
1 parent 98a57e8 commit dbba1de
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/renderer/components/dialogs/ViewGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 && (
Expand Down Expand Up @@ -238,6 +262,32 @@ function ViewGroupInner(props: {
{groupName} {chat.isProtected && <InlineVerifiedIcon />}
</p>
</div>
<div className='group-separator'>
{tx('profile_shared_chats')}
</div>
<div style={{ marginLeft: '-20px' }}>
<ChatListPart
isRowLoaded={isChatLoaded}
loadMoreRows={loadChats}
rowCount={chatListIds.length}
width={'400px'}
height={CHATLISTITEM_CHAT_HEIGHT * chatListIds.length}
itemKey={index => 'key' + chatListIds[index]}
itemHeight={CHATLISTITEM_CHAT_HEIGHT}
>
{({ index, style }) => {
const [chatId] = chatListIds[index]
return (
<div style={style}>
<ChatListItem
chatListItem={chatCache[chatId] || undefined}
onClick={onChatClick.bind(null, chatId)}
/>
</div>
)
}}
</ChatListPart>
</div>
<div className='group-separator'>
{!isBroadcast
? tx(
Expand Down

0 comments on commit dbba1de

Please sign in to comment.