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: mention draft update [WPB-12062] #3865

Merged
merged 1 commit into from
Feb 7, 2025
Merged

Conversation

Garzas
Copy link
Contributor

@Garzas Garzas commented Feb 7, 2025

TaskWPB-12062 [Android] add mentions to draft messages


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

  • Fixed a race condition in MessageCompositionHolder where mentions were not always properly saved in the message draft.
  • Previously, the mention text could be inserted before selectedMentions was updated, leading to cases where the draft was saved without the correct mention data.

Causes (Optional)

  • The issue was caused by an incorrect order of operations:
    • insertMentionIntoText(mention) was called before updating selectedMentions, modifying messageTextState immediately.
    • This could lead to onSaveDraft() being triggered with an outdated selectedMentions list, causing mentions to be missing from the draft.

Solutions

  • Reordered the operations to ensure selectedMentions is updated before inserting the mention into the text:
    messageComposition.update {
        it.copy(
            selectedMentions = it.selectedMentions.plus(mention).sortedBy { it.start }
        )
    }
    insertMentionIntoText(mention) // Now safely modifying text after updating mentions

@Garzas Garzas self-assigned this Feb 7, 2025
@Garzas Garzas changed the title fix: mention draft update fix: mention draft update [WPB-12062] Feb 7, 2025
Copy link

sonarqubecloud bot commented Feb 7, 2025

@Garzas Garzas enabled auto-merge February 7, 2025 09:51
@Garzas Garzas added this pull request to the merge queue Feb 7, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.46%. Comparing base (24cdf16) to head (9d2e032).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3865   +/-   ##
========================================
  Coverage    45.46%   45.46%           
========================================
  Files          491      491           
  Lines        17008    17008           
  Branches      2846     2846           
========================================
+ Hits          7732     7733    +1     
+ Misses        8489     8488    -1     
  Partials       787      787           
Files with missing lines Coverage Δ
.../messagecomposer/state/MessageCompositionHolder.kt 46.51% <100.00%> (ø)

... and 1 file 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 24cdf16...9d2e032. Read the comment docs.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Built wire-android-staging-compat-pr-3865.apk is available for download

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Built wire-android-dev-debug-pr-3865.apk is available for download

Merged via the queue into develop with commit 038c90a Feb 7, 2025
14 of 16 checks passed
@Garzas Garzas deleted the fix/mention-draft-update branch February 7, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants