From 9e6e6fa8306564c746ddab880e700ab9f2b064c0 Mon Sep 17 00:00:00 2001
From: SimonLaux
Date: Thu, 28 Sep 2023 03:21:07 +0200
Subject: [PATCH] diable by default and add a switch for it in settings
---
.../dialogs/Settings-ExperimentalFeatures.tsx | 4 ++
src/renderer/components/dialogs/ViewGroup.tsx | 69 +++++++++++--------
src/shared/shared-types.d.ts | 1 +
src/shared/state.ts | 1 +
4 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx b/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx
index c95689b5d2..284b160ca9 100644
--- a/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx
+++ b/src/renderer/components/dialogs/Settings-ExperimentalFeatures.tsx
@@ -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',
diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx
index a2422aff31..65eb06ac72 100644
--- a/src/renderer/components/dialogs/ViewGroup.tsx
+++ b/src/renderer/components/dialogs/ViewGroup.tsx
@@ -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')
@@ -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([])
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,
@@ -265,30 +268,36 @@ function ViewGroupInner(props: {
{groupName} {chat.isProtected && }
- {tx('group_related_chats')}
-
-
'key' + chatListIds[index]}
- itemHeight={CHATLISTITEM_CHAT_HEIGHT}
- >
- {({ index, style }) => {
- const chatId = chatListIds[index]
- return (
-
-
-
- )
- }}
-
-
+ {isRelatedChatsEnabled && (
+ <>
+
+ {tx('group_related_chats')}
+
+
+
'key' + chatListIds[index]}
+ itemHeight={CHATLISTITEM_CHAT_HEIGHT}
+ >
+ {({ index, style }) => {
+ const chatId = chatListIds[index]
+ return (
+
+
+
+ )
+ }}
+
+
+ >
+ )}
{!isBroadcast
? tx(
diff --git a/src/shared/shared-types.d.ts b/src/shared/shared-types.d.ts
index e51e74276c..0d3e129f0c 100644
--- a/src/shared/shared-types.d.ts
+++ b/src/shared/shared-types.d.ts
@@ -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 {
diff --git a/src/shared/state.ts b/src/shared/state.ts
index ddf1f310f6..ee33098582 100644
--- a/src/shared/state.ts
+++ b/src/shared/state.ts
@@ -29,5 +29,6 @@ export function getDefaultState(): DesktopSettingsType {
enableWebxdcDevTools: false,
HTMLEmailAskForRemoteLoadingConfirmation: true,
HTMLEmailAlwaysLoadRemoteContent: false,
+ EnableRelatedChats: false,
}
}