-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: duplicate 1-1 conversations - WPB-10260 #2006
base: chore/cleanup-phone-number-WPB-11437
Are you sure you want to change the base?
fix: duplicate 1-1 conversations - WPB-10260 #2006
Conversation
0bee456
to
fd72b45
Compare
Test Results3 689 tests 3 689 ✅ 9m 4s ⏱️ Results for commit fd72b45. |
@@ -97,6 +97,10 @@ final class OneOnOneConversationMigrationAction: CoreDataMigrationAction { | |||
sameParticipant | |||
]) | |||
|
|||
// 4. sort by their fully qualified conversation ID in ascending oder, and use the first one. | |||
// primary_key is basically the qualified id | |||
request.sortDescriptors = [NSSortDescriptor(key: "primaryKey", ascending: true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the reason why, given two team one on ones, client A might show one and client B might show the other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? can you give an example?
if fakeOnOnOnePerUser[otherUser] == nil { | ||
fakeOnOnOnePerUser[otherUser] = [conversation] | ||
} else { | ||
fakeOnOnOnePerUser[otherUser]?.append(conversation) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can achieve this with:
fakeOneOnOnePerUser[otherUser, default: [])?.append(conversation)
return | ||
} | ||
|
||
let fakeOneOnOnePerUser = conversationsPerUser(from: fake1On1Conversations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elsewhere in our code we often name dictionaries as "valueByKey", so in this case conversationsByUser
.
} | ||
} | ||
|
||
private func fakeOneOnOneConversations(context: NSManagedObjectContext) throws -> [ZMConversation] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to define once and reuse it?
@@ -305,6 +305,29 @@ public extension ZMConversation { | |||
|
|||
return try context.fetch(request) | |||
} | |||
|
|||
static func fetchAllFakeOneOnOneGroupConversations( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename the file since fake one on ones only concern proteus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
|
||
private func moveMessages(from otherConversation: ZMConversation, | ||
to theOneOnOneConversation: ZMConversation) { | ||
otherConversation.allMessages.forEach { message in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: I don't think the specifics of the content in the method are tested... eg. visible vs hidden, draft properties. Consider testing this if it is not too much trouble.
Issue
Note: this PR is based on #2017, so preferably start with #2017 first.
Due to some race condition, an user could end up with duplicate proteus team 1-1 conversation. This PR aims to fix this, by showing only one same on all platforms 1-1 conversation.
Testing
Checklist
[WPB-XXX]
.