Fix issue with poor sent video viewing behavior.

This commit is contained in:
Alex Hart
2022-12-02 10:43:31 -04:00
parent 591d8c3d1a
commit 9aca0af22c
2 changed files with 19 additions and 3 deletions

View File

@@ -697,6 +697,7 @@ public class AttachmentTable extends DatabaseTable {
contentValues.put(HEIGHT, sourceAttachment.getHeight());
contentValues.put(CONTENT_TYPE, sourceAttachment.getContentType());
contentValues.put(VISUAL_HASH, getVisualHashStringOrNull(sourceAttachment));
contentValues.put(TRANSFORM_PROPERTIES, sourceAttachment.getTransformProperties().serialize());
database.update(TABLE_NAME, contentValues, PART_ID_WHERE, destinationId.toStrings());
}
@@ -1604,7 +1605,7 @@ public class AttachmentTable extends DatabaseTable {
return new TransformProperties(true, false, 0, 0, sentMediaQuality);
}
@NonNull String serialize() {
public @NonNull String serialize() {
return JsonUtil.toJson(this);
}

View File

@@ -13,6 +13,7 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.StoryTextPost
import org.thoughtcrime.securesms.stories.viewer.page.StoryPost
import org.thoughtcrime.securesms.util.Base64
import org.thoughtcrime.securesms.util.rx.RxStore
import kotlin.time.Duration
import kotlin.time.Duration.Companion.microseconds
class StoryPostViewModel(private val repository: StoryTextPostRepository) : ViewModel() {
@@ -40,11 +41,25 @@ class StoryPostViewModel(private val repository: StoryTextPostRepository) : View
store.update { StoryPostState.None() }
} else if (storyPostContent.isVideo()) {
store.update {
val shouldSkipTransform = storyPostContent.attachment.transformProperties.shouldSkipTransform()
val clipStart: Duration = if (shouldSkipTransform) {
0L.microseconds
} else {
storyPostContent.attachment.transformProperties.videoTrimStartTimeUs.microseconds
}
val clipEnd: Duration = if (shouldSkipTransform) {
0L.microseconds
} else {
storyPostContent.attachment.transformProperties.videoTrimEndTimeUs.microseconds
}
StoryPostState.VideoPost(
videoUri = storyPostContent.uri,
size = storyPostContent.attachment.size,
clipStart = storyPostContent.attachment.transformProperties.videoTrimStartTimeUs.microseconds,
clipEnd = storyPostContent.attachment.transformProperties.videoTrimEndTimeUs.microseconds,
clipStart = clipStart,
clipEnd = clipEnd,
blurHash = storyPostContent.attachment.blurHash
)
}