From 583faa14b476ea21ced5000117231b1c22c5d3fe Mon Sep 17 00:00:00 2001 From: Virgile <78490891+V-Gira@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:15:07 +0100 Subject: [PATCH] fix(mls-migration): align with other clients on which proteus converstaion to migrate (WPB-12162) (#18387) --- src/script/conversation/ConversationRepository.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/script/conversation/ConversationRepository.ts b/src/script/conversation/ConversationRepository.ts index 6a8ab7cff43..c3184cdd500 100644 --- a/src/script/conversation/ConversationRepository.ts +++ b/src/script/conversation/ConversationRepository.ts @@ -1620,8 +1620,10 @@ export class ConversationRepository { ), ); - const mostRecentlyUsedProteusConversation = proteusConversations.sort( - (a, b) => b.last_event_timestamp() - a.last_event_timestamp(), + // In the event that multiple 1:1 Proteus conversations exist, we migrate the one with the lowest id + // See https://wearezeta.atlassian.net/wiki/spaces/ENGINEERIN/pages/1344602120/Use+case+multiple+1+1+conversation+in+teams+Proteus + const proteusConversationToBeKept = proteusConversations.sort((a, b) => + a.qualifiedId.id.localeCompare(b.qualifiedId.id), )[0]; // Before we delete the proteus 1:1 conversation, we need to make sure all the local properties are also migrated @@ -1638,7 +1640,7 @@ export class ConversationRepository { mutedTimestamp, status, verification_state, - } = mostRecentlyUsedProteusConversation; + } = proteusConversationToBeKept; const updates: Partial> = { archivedState: archivedState(),