Skip to content
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: 1:1s end up at the bottom of the list after migration [WPB-15452] #3232

Merged
merged 3 commits into from
Jan 24, 2025

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Jan 16, 2025

BugWPB-15452 [Android] 1:1s end up at the bottom of the list after migration


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

1:1 conversations, after MLS migration, are moved to the bottom of the conversation list, even if the conversation has some messages sent or received in the meantime.

Causes (Optional)

This is due to the fact that when migrating 1:1, a new conversation with different id is created, so in theory this new one doesn’t have any events thus lastEventTime and last_modified_date are empty (01.01.1970) - that’s why it’s moved to the bottom of the list as the query. It creates confusion and inconsistency in sorting as now, even if a conversation had some messages, which are migrated to the new one.

Solutions

Update last_modified_date when migrating history (messages) - take the value from previous proteus conversation or set a current time otherwise (if there's no previous proteus conversation then it means it's a completely new one so it should be at the top anyway).

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Have proteus 1:1, send and receive some messages, migrate to MLS, check whether the conversation is still on the proper position on a list.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@echoes-hq echoes-hq bot added the echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. label Jan 16, 2025
Copy link
Contributor

github-actions bot commented Jan 16, 2025

Test Results

3 405 tests  +2   3 297 ✅ +2   5m 51s ⏱️ +32s
  584 suites ±0     108 💤 ±0 
  584 files   ±0       0 ❌ ±0 

Results for commit 94d3e5d. ± Comparison against base commit 7611f05.

This pull request removes 1 and adds 3 tests. Note that renamed tests count towards both.
com.wire.kalium.logic.feature.conversation.mls.OneOnOneMigratorTest ‑ givenExistingTeamOneOnOne_whenMigratingToProteus_thenShouldNOTCreateGroupConversation[jvm]
com.wire.kalium.logic.feature.conversation.mls.OneOnOneMigratorTest ‑ givenNoProteusConversation_whenMigratingToMLS_thenUpdateLastModifiedDateToBeCurrentDate[jvm]
com.wire.kalium.logic.feature.conversation.mls.OneOnOneMigratorTest ‑ givenProteusConversation_whenMigratingToMLS_thenUpdateLastModifiedDateFromOriginalConversation[jvm]
com.wire.kalium.logic.feature.conversation.mls.OneOnOneMigratorTest ‑ givenUnassignedOneOnOne_whenMigratingToProteus_thenShouldAssignOneOnOneConversation[jvm]

♻️ This comment has been updated with latest results.

Comment on lines +151 to +162
).map {
// Emit most recent last modified date of the proteus conversations to pass it to the target conversation
conversationRepository.getConversationById(proteusOneOnOneConversation).getOrNull()?.lastModifiedDate.let {
listOfNotNull(lastModifiedDate, it).maxOrNull()
}
}
}.map { lastModifiedDate ->
// Fallback to current time if not found as it means that it's completely new conversation without any history
lastModifiedDate ?: currentInstant()
}
}.flatMap { lastModifiedDate ->
conversationRepository.updateConversationModifiedDate(targetConversation, lastModifiedDate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do the same in the query that does the update to avoid updating

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure whether moveMessages query should have any side effects and we don't update it for every message type so we would need to duplicate the logic from persistMessage and MessageContent.shouldUpdateConversationOrder() into sql, also, I think it would be harder to set current time as iso string directly in sql 🤔

Copy link
Contributor

@saleniuk saleniuk requested a review from MohamadJaara January 16, 2025 12:55
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 54.45%. Comparing base (7611f05) to head (94d3e5d).

Files with missing lines Patch % Lines
...logic/feature/conversation/mls/OneOnOneMigrator.kt 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3232      +/-   ##
===========================================
- Coverage    54.47%   54.45%   -0.03%     
===========================================
  Files         1269     1269              
  Lines        36964    36971       +7     
  Branches      3745     3747       +2     
===========================================
- Hits         20137    20132       -5     
- Misses       15414    15426      +12     
  Partials      1413     1413              
Files with missing lines Coverage Δ
...logic/feature/conversation/mls/OneOnOneMigrator.kt 79.22% <90.90%> (-13.64%) ⬇️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7611f05...94d3e5d. Read the comment docs.

@datadog-wireapp
Copy link

Datadog Report

Branch report: fix/update-last-modified-date-when-migrating-1on1
Commit report: fd63e6e
Test service: kalium-jvm

✅ 0 Failed, 3297 Passed, 108 Skipped, 1m 1.84s Total Time

@saleniuk saleniuk added this pull request to the merge queue Jan 24, 2025
Merged via the queue into develop with commit 544ccea Jan 24, 2025
23 checks passed
@saleniuk saleniuk deleted the fix/update-last-modified-date-when-migrating-1on1 branch January 24, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap/bug Work contributing to resolve a bug not critical enough to have raised an incident. 🚨 Potential breaking changes 👕 size: M type: bug / fix 🐞
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants