From e8fe564a0856e0059fa4d4c4332a7664661f6144 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 7 Sep 2022 11:10:10 +1000 Subject: [PATCH] fix: show sogs without display name in convo list also use the pollinfo to update whatever the displayname if needed --- ts/models/conversation.ts | 6 ++++++ .../apis/open_group_api/opengroupV2/JoinOpenGroupV2.ts | 4 ++++ .../apis/open_group_api/opengroupV2/OpenGroupManagerV2.ts | 2 ++ ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts | 4 +++- ts/state/selectors/conversations.ts | 8 -------- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 73d3be41e..fd2fe7f21 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -1514,6 +1514,7 @@ export class ConversationModel extends Backbone.Model { details: { admins?: Array; image_id?: number; + name?: string; moderators?: Array; hidden_admins?: Array; hidden_moderators?: Array; @@ -1562,6 +1563,11 @@ export class ConversationModel extends Backbone.Model { type: 'mods', }); + if (details.name && details.name !== this.getRealSessionUsername()) { + hasChange = hasChange || true; + this.setSessionDisplayNameNoCommit(details.name); + } + hasChange = hasChange || modsChanged; if (this.isOpenGroupV2() && details.image_id && isNumber(details.image_id)) { diff --git a/ts/session/apis/open_group_api/opengroupV2/JoinOpenGroupV2.ts b/ts/session/apis/open_group_api/opengroupV2/JoinOpenGroupV2.ts index 7b0365f35..59016df57 100644 --- a/ts/session/apis/open_group_api/opengroupV2/JoinOpenGroupV2.ts +++ b/ts/session/apis/open_group_api/opengroupV2/JoinOpenGroupV2.ts @@ -134,6 +134,10 @@ export async function joinOpenGroupV2WithUIEvents( const alreadyExist = hasExistingOpenGroup(parsedRoom.serverUrl, parsedRoom.roomId); const conversationID = getOpenGroupV2ConversationId(parsedRoom.serverUrl, parsedRoom.roomId); if (alreadyExist || getConversationController().get(conversationID)) { + const existingConvo = getConversationController().get(conversationID); + await existingConvo.setDidApproveMe(true, false); + await existingConvo.setIsApproved(true, false); + await existingConvo.commit(); if (showToasts) { ToastUtils.pushToastError('publicChatExists', window.i18n('publicChatExists')); } diff --git a/ts/session/apis/open_group_api/opengroupV2/OpenGroupManagerV2.ts b/ts/session/apis/open_group_api/opengroupV2/OpenGroupManagerV2.ts index 787d65d27..c6a6e4ac5 100644 --- a/ts/session/apis/open_group_api/opengroupV2/OpenGroupManagerV2.ts +++ b/ts/session/apis/open_group_api/opengroupV2/OpenGroupManagerV2.ts @@ -197,6 +197,8 @@ export class OpenGroupManagerV2 { active_at: Date.now(), displayNameInProfile: room.roomName, isApproved: true, + didApproveMe: true, + isTrustedForAttachmentDownload: true, // we always trust attachments when sent to an opengroup }); await conversation.commit(); diff --git a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts index c8e8ce1dc..dbaa248de 100644 --- a/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts +++ b/ts/session/apis/open_group_api/sogsv3/sogsApiV3.ts @@ -77,6 +77,7 @@ async function handlePollInfoResponse( details: { admins?: Array; image_id: number; + name?: string; moderators?: Array; hidden_admins?: Array; hidden_moderators?: Array; @@ -122,7 +123,8 @@ async function handlePollInfoResponse( 'image_id', 'moderators', 'hidden_admins', - 'hidden_moderators' + 'hidden_moderators', + 'name' ), }); } diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 73922ef10..9aebfcc3c 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -419,14 +419,6 @@ export const _getSortedConversations = ( }; } - // Add Open Group to list as soon as the name has been set - if ( - conversation.isPublic && - (!conversation.displayNameInProfile || conversation.displayNameInProfile === 'Unknown group') - ) { - continue; - } - // Remove all invalid conversations and conversatons of devices associated // with cancelled attempted links if (!conversation.isPublic && !conversation.activeAt) {