Skip to content

Commit

Permalink
diable by default and add a switch for it
Browse files Browse the repository at this point in the history
in settings
  • Loading branch information
Simon-Laux committed Sep 28, 2023
1 parent 531e22e commit 9e6e6fa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export function SettingsExperimentalFeatures({
key: 'enableChatAuditLog',
label: tx('menu_chat_audit_log'),
})}
{renderDTSettingSwitch({
key: 'EnableRelatedChats',
label: tx('group_related_chats'),
})}
{renderDTSettingSwitch({
key: 'experimentalEnableMarkdownInMessages',
label: 'Render Markdown in Messages',
Expand Down
69 changes: 39 additions & 30 deletions src/renderer/components/dialogs/ViewGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { selectedAccountId } from '../../ScreenController'
import { modifyGroup } from '../helpers/ChatMethods'
import { DcEventType } from '@deltachat/jsonrpc-client'
import { InlineVerifiedIcon } from '../VerifiedIcon'
import { useSettingsStore } from '../../stores/settings'

const log = getLogger('renderer/ViewGroup')

Expand Down Expand Up @@ -139,16 +140,18 @@ function ViewGroupInner(props: {
const { openDialog } = useContext(ScreenContext)
const { onClose, chat, isBroadcast } = props
const tx = useTranslationFunction()
const [settings] = useSettingsStore()
const isRelatedChatsEnabled =
settings?.desktopSettings.EnableRelatedChats || false

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

useEffect(() => {
BackendRemote.rpc
.getSimilarChatIds(selectedAccountId(), chat.id)
.then(chatIds => {
setChatListIds(chatIds)
})
}, [chat.id])
if (isRelatedChatsEnabled)
BackendRemote.rpc
.getSimilarChatIds(selectedAccountId(), chat.id)
.then(chatIds => setChatListIds(chatIds))
}, [chat.id, isRelatedChatsEnabled])

const { isChatLoaded, loadChats, chatCache } = useLogicVirtualChatList(
chatListIds,
Expand Down Expand Up @@ -265,30 +268,36 @@ function ViewGroupInner(props: {
{groupName} {chat.isProtected && <InlineVerifiedIcon />}
</p>
</div>
<div className='group-separator'>{tx('group_related_chats')}</div>
<div className='group-related-chats-list-wrapper'>
<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>
{isRelatedChatsEnabled && (
<>
<div className='group-separator'>
{tx('group_related_chats')}
</div>
<div className='group-related-chats-list-wrapper'>
<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
1 change: 1 addition & 0 deletions src/shared/shared-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface DesktopSettingsType {
HTMLEmailAskForRemoteLoadingConfirmation: boolean
/** always loads remote content without asking, for non contact requests */
HTMLEmailAlwaysLoadRemoteContent: boolean
EnableRelatedChats: boolean
}

export interface RC_Config {
Expand Down
1 change: 1 addition & 0 deletions src/shared/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ export function getDefaultState(): DesktopSettingsType {
enableWebxdcDevTools: false,
HTMLEmailAskForRemoteLoadingConfirmation: true,
HTMLEmailAlwaysLoadRemoteContent: false,
EnableRelatedChats: false,
}
}

0 comments on commit 9e6e6fa

Please sign in to comment.