-
Notifications
You must be signed in to change notification settings - Fork 232
Media upload cancellation #1058
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
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 actually have no idea why this screenshot was updated 🤔 .
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #1058 +/- ##
===========================================
+ Coverage 56.91% 56.98% +0.06%
===========================================
Files 997 999 +2
Lines 25343 25407 +64
Branches 5077 5090 +13
===========================================
+ Hits 14424 14477 +53
- Misses 8696 8705 +9
- Partials 2223 2225 +2
☔ View full report in Codecov by Sentry. |
c73f915
to
cb8c096
Compare
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.
Nice work.
I tried to send an image and cancel the upload. I was still on the image preview, like if the image had not been sent. But the image was sent in the timeline.
}, | ||
onFailure = { | ||
sendActionState.value = SendActionState.Failure(it) | ||
).getOrThrow() |
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 am not sure. Is this .getOrThrow()
necessary?
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.
We need it to catch the CancellationException
that won't come inside the Result
. I tried several ways to get it wrapped inside this Result, but none of them worked.
) = launch { | ||
when (attachment) { | ||
is Attachment.Media -> { | ||
) = when (attachment) { |
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.
There is some code duplication in the class AttachmentsPreviewPresenter
, is there a (easy) way to reduce this?
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.
The 2 functions are quite similar, but they pass different data to their sendMedia
counterparts. We could try wrapping those in some use case or helper class, but I'm not sure it's worth it for just 2 occurrences. Also, I think we want to remove the upload progress from the AttachmentsPreviewView
in the future as display it on the the timeline item instead, so part of this code will probably disappear.
...roidutils/src/main/kotlin/io/element/android/libraries/androidutils/diff/DiffCacheUpdater.kt
Outdated
Show resolved
Hide resolved
...mpl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/MediaUploadHandlerImpl.kt
Outdated
Show resolved
Hide resolved
...aupload/api/src/test/kotlin/io/element/android/libraries/mediaupload/api/MediaSenderTests.kt
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
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.
Thanks for the update and for your answers!
I just saw this, sorry. Unless the upload takes long it's quite difficult to cancel it, and images are usually quite fast, so maybe the cancellation happened after the file has been uploaded but before we got the response from the server as a timeline item. |
Changes
MediaUploadHandler
as an abstraction overSendAttachmentJoinHandler
.Why
Closes #769 .