Use the text already in the composer as the attachment caption - #7465
Open
hayaksi1 wants to merge 1 commit into
Open
Use the text already in the composer as the attachment caption#7465hayaksi1 wants to merge 1 commit into
hayaksi1 wants to merge 1 commit into
Conversation
Typing a message and then picking an image opened the attachment preview with an empty caption editor, so the text had to be retyped and the original was still sitting in the composer afterwards. The composer's text now travels forwards to the preview as the initial caption, on the existing parcelable navigation target. A single room-scoped bit travels back to say that a handed-over caption was actually sent, keyed by timeline mode so a live composer and a thread composer cannot clear each other, and the composer clears itself and deletes its saved draft on its next composition. Clearing on send rather than on hand-over is deliberate. Cancelling the preview reports nothing, so the text is still there, restored by the composer's own saveable state and by the draft that Appyx's pause of the off-screen composer persists. If the back-channel bit is ever lost the user keeps a duplicate copy, which is a better failure than losing what they typed. A pending edit hands over nothing and is left untouched, and a caption typed only inside the preview never travels back.
Contributor
|
Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7465 +/- ##
===========================================
- Coverage 80.66% 80.64% -0.02%
===========================================
Files 2772 2773 +1
Lines 80812 80832 +20
Branches 11055 11058 +3
===========================================
+ Hits 65183 65189 +6
- Misses 11362 11381 +19
+ Partials 4267 4262 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Content
Typing a message and then picking an image opened the attachment preview with an empty caption editor, so the text had to be retyped, and the original was still sitting in the composer after the image was sent.
The composer's text now travels forwards to the preview as the initial caption, carried on the existing parcelable navigation target. A single room-scoped bit travels back to say that a handed-over caption was actually sent, keyed by
Timeline.Mode, and the composer clears itself and deletes its saved draft on its next composition.Clearing on send rather than on hand-over is deliberate. Cancelling the preview reports nothing, so the typed text is still there, restored by the composer's own saveable state and by the draft that Appyx's pause of the off-screen composer persists. If the back-channel bit is ever lost, for example to process death while the preview is open, the user keeps a duplicate copy of their text, which is a better failure than losing it.
Two cases are deliberately left alone. A pending edit hands over nothing and is not cleared, so the text being edited still edits the original on the next send. And
MessageComposerEvent.SendUri, the share-into-app and keyboard-image path, bypasses the preview entirely and is unchanged.Keying the hand-over on the timeline mode is what keeps a live composer and a thread composer from clearing each other; they share one room-scoped composer context, so a plain flag would not have been safe.
Motivation and context
Part of #5224.
Tests
features/messages/impl/.../attachments/AttachmentsPreviewPresenterTest.kt: a handed-over caption pre-fills the caption editor and no caption leaves it empty; sending reports the caption as sent, sending without one reports nothing, and cancelling reports nothing; sending in a thread reports the caption for that thread only.features/messages/impl/.../messagecomposer/MessageComposerPresenterTest.kt: picking an image hands the composer text over, hands over nothing when the composer is empty, and hands over nothing while editing; the composer is cleared and its draft deleted once a handed-over caption has been sent; a caption sent in a thread does not clear the live composer.Run with
./gradlew :features:messages:impl:testDebugUnitTest.Rich-text formatting is flattened to markdown by the hand-over, which is what a caption can carry today; converting a caption to HTML is separate scope.
Tested devices
Checklist