@@ -42,9 +42,19 @@ import { unknownErrorToString } from '../helpers/unknownErrorToString'
4242import { getLogger } from '@deltachat-desktop/shared/logger'
4343const log = getLogger ( 'ViewGroup' )
4444
45+ /**
46+ * This dialog is used to for groups of various types:
47+ * - encrypted groups
48+ * - non encrypted groups (email groups)
49+ * - channels if the current account is the sender (DC_CHAT_TYPE_OUT_BROADCAST)
50+ *
51+ * Mailinglists and channels (receiver side) have an own dialog
52+ * since you don't see other receivers in those chats
53+ * (see MailingListProfile)
54+ */
4555export default function ViewGroup (
4656 props : {
47- chat : T . FullChat
57+ chat : Parameters < typeof ViewGroupInner > [ 0 ] [ 'chat' ]
4858 } & DialogProps
4959) {
5060 const { chat, onClose } = props
@@ -173,7 +183,9 @@ export const useGroup = (accountId: number, chat: T.FullChat) => {
173183
174184function ViewGroupInner (
175185 props : {
176- chat : T . FullChat
186+ chat : T . FullChat & {
187+ chatType : C . DC_CHAT_TYPE_GROUP | C . DC_CHAT_TYPE_OUT_BROADCAST
188+ }
177189 } & DialogProps
178190) {
179191 const { chat, onClose } = props
@@ -298,7 +310,7 @@ function ViewGroupInner(
298310 groupImage,
299311 groupColor : chat . color ,
300312 onOk : ( groupName : string , groupImage : string | null ) => {
301- //(treefit): TODO this check should be way earlier, you should not be able to "OK" the dialog if there is no group name
313+ // TODO this check should be way earlier, you should not be able to "OK" the dialog if there is no group name
302314 if ( groupName . length > 1 ) {
303315 setGroupName ( groupName )
304316 }
@@ -309,15 +321,22 @@ function ViewGroupInner(
309321 } )
310322 }
311323
312- // Note that this might also need `C.DC_GCL_ADDRESS` for unencrypted groups,
313- // but we're not supposed to display this component for those.
314324 const listFlags = C . DC_GCL_ADD_SELF
315325
316326 // Note that we are not checking `chat.isEncrypted`,
317327 // unlike in "New E-Mail" dialog.
318328 // See https://github.com/deltachat/deltachat-desktop/issues/5294
319329 // > the chat itself picks up "group wording"
320330 const membersOrRecipients = isBroadcast ? 'recipients' : 'members'
331+
332+ // We don't allow editing of non encryped groups (email groups)
333+ // i.e. changing name, avatar or recipients
334+ // since it cannot be guaranteed that the recipients will adapt
335+ // these changes (image is not shown at all in MTAs, group name is
336+ // just the subject and recipients are basically just an email
337+ // distribution list)
338+ const allowEdit = ! chatDisabled && group . isEncrypted
339+
321340 const showAddMemberDialog = ( ) => {
322341 openDialog ( AddMemberDialog , {
323342 listFlags,
@@ -355,12 +374,21 @@ function ViewGroupInner(
355374 < >
356375 { ! profileContact && (
357376 < >
358- < DialogHeader
359- title = { ! isBroadcast ? tx ( 'tab_group' ) : tx ( 'channel' ) }
360- onClickEdit = { onClickEdit }
361- onClose = { onClose }
362- dataTestid = 'view-group-dialog-header'
363- />
377+ { allowEdit && (
378+ < DialogHeader
379+ title = { ! isBroadcast ? tx ( 'tab_group' ) : tx ( 'channel' ) }
380+ onClickEdit = { onClickEdit }
381+ onClose = { onClose }
382+ dataTestid = 'view-group-dialog-header'
383+ />
384+ ) }
385+ { ! allowEdit && (
386+ < DialogHeader
387+ title = { tx ( 'tab_group' ) }
388+ onClose = { onClose }
389+ dataTestid = 'view-group-dialog-header'
390+ />
391+ ) }
364392 < DialogBody >
365393 < DialogContent paddingBottom >
366394 < ProfileInfoHeader
@@ -431,7 +459,7 @@ function ViewGroupInner(
431459 < RovingTabindexProvider
432460 wrapperElementRef = { groupMemberContactListWrapperRef }
433461 >
434- { ! chatDisabled && (
462+ { ! chatDisabled && group . isEncrypted && (
435463 < >
436464 < PseudoListItemAddMember
437465 onClick = { ( ) => showAddMemberDialog ( ) }
@@ -446,7 +474,7 @@ function ViewGroupInner(
446474 ) }
447475 < ContactList
448476 contacts = { group . contacts }
449- showRemove = { ! chatDisabled }
477+ showRemove = { ! chatDisabled && group . isEncrypted }
450478 onClick = { contact => {
451479 if ( contact . id === C . DC_CONTACT_ID_SELF ) {
452480 return
0 commit comments