mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-14 17:24:01 +01:00
Fix issue with v3 preupload.
This commit is contained in:
committed by
Greyson Parrelli
parent
e3a7a9c876
commit
196c33c62b
@@ -711,23 +711,6 @@ class MediaSendFlowViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies updates to selected media (old -> new).
|
||||
*/
|
||||
fun applyMediaUpdates(oldToNew: Map<Media, Media>) {
|
||||
if (oldToNew.isEmpty()) return
|
||||
|
||||
mutateSelection {
|
||||
val snapshot = state.value
|
||||
val updatedSelection = snapshot.selectedMedia.map { oldToNew[it] ?: it }
|
||||
updateState { copy(selectedMedia = updatedSelection) }
|
||||
|
||||
preUploadController.applyMediaUpdates(oldToNew, snapshot.recipientId)
|
||||
preUploadController.updateCaptions(updatedSelection)
|
||||
preUploadController.updateDisplayOrder(updatedSelection)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current ordering of selected media.
|
||||
*/
|
||||
@@ -1324,8 +1307,8 @@ class MediaSendFlowViewModel(
|
||||
/**
|
||||
* A flow that picks its destination mid-flight has nothing to attribute an upload to yet, so it waits for the send.
|
||||
*/
|
||||
private fun shouldPreUpload(metered: Boolean): Boolean {
|
||||
return !metered && args.mode != MediaSendFlowActivityContract.Mode.ChooseAfterMediaSelection
|
||||
private fun MediaSendFlowState.shouldPreUpload(metered: Boolean): Boolean {
|
||||
return !metered && !isContactSelectionRequired
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
-35
@@ -72,41 +72,6 @@ class PreUploadController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a map of old->new, cancel medias that were changed and upload their replacements. Will
|
||||
* also upload any media in the map that wasn't yet uploaded.
|
||||
*
|
||||
* @param oldToNew A mapping of prior media objects to their updated equivalents.
|
||||
* @param recipientId Optional recipient identifier. Used by the callback to apply recipient-specific behavior.
|
||||
*/
|
||||
fun applyMediaUpdates(oldToNew: Map<Media, Media>, recipientId: MediaRecipientId?) {
|
||||
executor.execute {
|
||||
for ((oldMedia, newMedia) in oldToNew) {
|
||||
val same = oldMedia == newMedia && hasSameTransformProperties(oldMedia, newMedia)
|
||||
|
||||
if (!same || !uploadResults.containsKey(newMedia.uri)) {
|
||||
Log.d(TAG, "Canceling existing preuploads.")
|
||||
cancelUploadInternal(oldMedia.uri)
|
||||
Log.d(TAG, "Applying media updates.")
|
||||
uploadMediaInternal(newMedia, recipientId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasSameTransformProperties(oldMedia: Media, newMedia: Media): Boolean {
|
||||
val oldProperties = oldMedia.transformProperties
|
||||
val newProperties = newMedia.transformProperties
|
||||
|
||||
if (oldProperties == null || newProperties == null) {
|
||||
return oldProperties == newProperties
|
||||
}
|
||||
|
||||
// Matches legacy behavior: if the new media is "video edited", we treat it as different.
|
||||
// Otherwise, we treat it as the same if only the sent quality matches.
|
||||
return !newProperties.videoEdited && oldProperties.sentMediaQuality == newProperties.sentMediaQuality
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the pre-upload (if present) for [media] and deletes any associated attachment state.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user