Fix several issues with stories.

fork-5.53.8
Alex Hart 2022-07-15 16:28:49 -03:00 zatwierdzone przez Cody Henthorne
rodzic aa75f1f8a7
commit b78633f9a7
4 zmienionych plików z 20 dodań i 38 usunięć

Wyświetl plik

@ -43,6 +43,7 @@ import org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult
import org.thoughtcrime.securesms.stories.Stories
import org.thoughtcrime.securesms.util.MessageUtil
import java.util.Collections
import java.util.Optional
import java.util.concurrent.TimeUnit
private val TAG = Log.tag(MediaSelectionRepository::class.java)
@ -237,7 +238,7 @@ class MediaSelectionRepository(context: Context) {
val storyPreUploadMessages: MutableMap<PreUploadResult, MutableList<OutgoingSecureMediaMessage>> = mutableMapOf()
val storyClipMessages: MutableList<OutgoingSecureMediaMessage> = ArrayList()
val distributionListPreUploadSentTimestamps: MutableMap<PreUploadResult, Long> = mutableMapOf()
val distributionListStoryClipsSentTimestamps: MutableMap<Media, Long> = mutableMapOf()
val distributionListStoryClipsSentTimestamps: MutableMap<MediaKey, Long> = mutableMapOf()
for (contact in contacts) {
val recipient = Recipient.resolved(contact.recipientId)
@ -304,7 +305,7 @@ class MediaSelectionRepository(context: Context) {
recipient,
body,
listOf(MediaUploadRepository.asAttachment(context, it)),
if (recipient.isDistributionList) distributionListStoryClipsSentTimestamps.getOrPut(it) { System.currentTimeMillis() } else System.currentTimeMillis(),
if (recipient.isDistributionList) distributionListStoryClipsSentTimestamps.getOrPut(it.asKey()) { System.currentTimeMillis() } else System.currentTimeMillis(),
-1,
TimeUnit.SECONDS.toMillis(recipient.expiresInSeconds.toLong()),
isViewOnce,
@ -357,4 +358,10 @@ class MediaSelectionRepository(context: Context) {
MessageSender.sendStories(context, storyClipMessages, null, null)
}
}
private fun Media.asKey(): MediaKey {
return MediaKey(this, this.transformProperties)
}
data class MediaKey(val media: Media, val mediaTransform: Optional<TransformProperties>)
}

Wyświetl plik

@ -123,10 +123,8 @@ object Stories {
@WorkerThread
private fun enqueueAttachmentsFromStoryForDownloadSync(record: MmsMessageRecord, ignoreAutoDownloadConstraints: Boolean) {
SignalDatabase.attachments.getAttachmentsForMessage(record.id).filterNot { it.isSticker }.forEach {
if (it.transferState == AttachmentDatabase.TRANSFER_PROGRESS_PENDING) {
val job = AttachmentDownloadJob(record.id, it.attachmentId, ignoreAutoDownloadConstraints)
ApplicationDependencies.getJobManager().add(job)
}
val job = AttachmentDownloadJob(record.id, it.attachmentId, ignoreAutoDownloadConstraints)
ApplicationDependencies.getJobManager().add(job)
}
if (record.hasLinkPreview()) {

Wyświetl plik

@ -57,19 +57,15 @@ class StorySlateView @JvmOverloads constructor(
callback?.onStateChanged(State.HIDDEN, postId)
}
if (this.state.isValidTransitionTo(state)) {
when (state) {
State.LOADING -> moveToProgressState(State.LOADING)
State.ERROR -> moveToErrorState()
State.RETRY -> moveToProgressState(State.RETRY)
State.NOT_FOUND -> moveToNotFoundState()
State.HIDDEN -> moveToHiddenState()
}
callback?.onStateChanged(state, postId)
} else {
Log.d(TAG, "Invalid state transfer: ${this.state} -> $state")
when (state) {
State.LOADING -> moveToProgressState(State.LOADING)
State.ERROR -> moveToErrorState()
State.RETRY -> moveToProgressState(State.RETRY)
State.NOT_FOUND -> moveToNotFoundState()
State.HIDDEN -> moveToHiddenState()
}
callback?.onStateChanged(state, postId)
}
fun setBackground(blur: BlurHash?) {
@ -161,24 +157,6 @@ class StorySlateView @JvmOverloads constructor(
NOT_FOUND(3, false),
HIDDEN(4, false);
fun isValidTransitionTo(newState: State): Boolean {
if (newState in listOf(HIDDEN, NOT_FOUND)) {
return true
}
if (newState == this) {
return true
}
return when (this) {
LOADING -> newState == ERROR
ERROR -> newState == RETRY
RETRY -> newState == ERROR
HIDDEN -> newState == LOADING
else -> false
}
}
companion object {
fun fromCode(code: Int): State {
return values().firstOrNull {

Wyświetl plik

@ -706,10 +706,9 @@ class StoryViewerPageFragment :
viewModel.setIsDisplayingSlate(true)
}
AttachmentDatabase.TRANSFER_PROGRESS_FAILED -> {
storySlate.moveToState(StorySlateView.State.NOT_FOUND, post.id)
storySlate.moveToState(StorySlateView.State.ERROR, post.id)
sharedViewModel.setContentIsReady()
viewModel.setIsDisplayingSlate(true)
markViewedIfAble()
}
}
}