From 9b3689c5d5bf65b16aa96d12b06449ebd0b1689f Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 7 Jan 2023 18:56:01 +0000 Subject: [PATCH 1/6] Add related chats to group profile --- CHANGELOG.md | 1 + src/renderer/components/dialogs/ViewGroup.tsx | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c966f0bab2..93e0a55e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,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. diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx index 4a87c83aa4..29d6823b06 100644 --- a/src/renderer/components/dialogs/ViewGroup.tsx +++ b/src/renderer/components/dialogs/ViewGroup.tsx @@ -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, @@ -136,6 +140,21 @@ function ViewGroupInner(props: { const { onClose, chat, isBroadcast } = props const tx = useTranslationFunction() + const [chatListIds, setChatListIds] = useState([]) + + 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 { @@ -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 && ( @@ -238,6 +265,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( From 85ac8dd12e9b36aee550349836cf8c8e3558f685 Mon Sep 17 00:00:00 2001 From: SimonLaux Date: Thu, 28 Sep 2023 02:22:50 +0200 Subject: [PATCH 2/6] Rename from "Shared Chats" into "Related Chats" in the group profile and add a translation string --- _locales/_untranslated_en.json | 3 +++ src/renderer/components/dialogs/ViewGroup.tsx | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/_locales/_untranslated_en.json b/_locales/_untranslated_en.json index ba82347b59..1c0056d686 100644 --- a/_locales/_untranslated_en.json +++ b/_locales/_untranslated_en.json @@ -73,5 +73,8 @@ }, "desktop_offer_copy_non_web_link_to_clipboard": { "message": "The link \"%1$d\" can not be opened in the web browser. Do you want to copy the link to the clipboard instead?" + }, + "group_related_chats": { + "message": "Related Chats" } } diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx index 29d6823b06..6e47d1a146 100644 --- a/src/renderer/components/dialogs/ViewGroup.tsx +++ b/src/renderer/components/dialogs/ViewGroup.tsx @@ -265,9 +265,7 @@ function ViewGroupInner(props: { {groupName} {chat.isProtected && }

-
- {tx('profile_shared_chats')} -
+
{tx('group_related_chats')}
Date: Thu, 28 Sep 2023 02:29:43 +0200 Subject: [PATCH 3/6] fix css bug --- scss/dialogs/_group-styles.scss | 5 +++++ src/renderer/components/dialogs/ViewGroup.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scss/dialogs/_group-styles.scss b/scss/dialogs/_group-styles.scss index 1d773de967..5c5d94f5db 100644 --- a/scss/dialogs/_group-styles.scss +++ b/scss/dialogs/_group-styles.scss @@ -46,6 +46,11 @@ div.group-member-contact-list-wrapper { margin-right: -20px; } +div.group-related-chats-list-wrapper { + margin-left: -20px; + margin-bottom: -20px; +} + div.group-image-wrapper { position: relative; div.group-image-edit-button { diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx index 6e47d1a146..a5a425c357 100644 --- a/src/renderer/components/dialogs/ViewGroup.tsx +++ b/src/renderer/components/dialogs/ViewGroup.tsx @@ -266,7 +266,7 @@ function ViewGroupInner(props: {

{tx('group_related_chats')}
-
+
Date: Thu, 28 Sep 2023 03:00:22 +0200 Subject: [PATCH 4/6] changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93e0a55e81..32edbb886b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added - mark webxdc app context as secure #3413 +- Experimental: Related Chats ### Changed - update deltachat-node and deltachat/jsonrpc-client to `v1.123.0` From 531e22e906a19d02ab6fb4c571f6fa2c1fe6a25f Mon Sep 17 00:00:00 2001 From: SimonLaux Date: Thu, 28 Sep 2023 03:06:02 +0200 Subject: [PATCH 5/6] adapt to breaking change in core 123 --- src/renderer/components/dialogs/ViewGroup.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/dialogs/ViewGroup.tsx b/src/renderer/components/dialogs/ViewGroup.tsx index a5a425c357..a2422aff31 100644 --- a/src/renderer/components/dialogs/ViewGroup.tsx +++ b/src/renderer/components/dialogs/ViewGroup.tsx @@ -144,9 +144,9 @@ function ViewGroupInner(props: { useEffect(() => { BackendRemote.rpc - .getSimilarChatlistEntries(selectedAccountId(), chat.id) - .then(entries => { - setChatListIds(entries.map(item => item[0])) + .getSimilarChatIds(selectedAccountId(), chat.id) + .then(chatIds => { + setChatListIds(chatIds) }) }, [chat.id]) From 9e6e6fa8306564c746ddab880e700ab9f2b064c0 Mon Sep 17 00:00:00 2001 From: SimonLaux Date: Thu, 28 Sep 2023 03:21:07 +0200 Subject: [PATCH 6/6] 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, } }