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 15, 2023
1 parent 70746da commit 8d461cd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Added
- Show video chat instance URLs as subtitles #3369
- Add similar chats to group profile #3379

### Changed
- Offer to copy non-HTTP links to the clipboard instead of trying to open them in webxdc source code link and inside of html emails.
Expand Down
53 changes: 53 additions & 0 deletions src/renderer/components/dialogs/ViewGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -136,6 +140,21 @@ function ViewGroupInner(props: {
const { onClose, chat, isBroadcast } = props
const tx = useTranslationFunction()

const [chatListIds, setChatListIds] = useState<number[]>([])

useEffect(() => {
BackendRemote.rpc
.getSimilarChatlistEntries(selectedAccountId(), chat.id)
.then(entries => {
setChatListIds(entries.map(item => item[0]))
})
}, [chat.id])

const { isChatLoaded, loadChats, chatCache } = useLogicVirtualChatList(
chatListIds,
null
)

const chatDisabled = !chat.canSend

const {
Expand Down Expand Up @@ -207,6 +226,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 +265,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={400}
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 8d461cd

Please sign in to comment.