kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix several issues with stories.
rodzic
aa75f1f8a7
commit
b78633f9a7
|
@ -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>)
|
||||
}
|
||||
|
|
|
@ -123,11 +123,9 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
if (record.hasLinkPreview()) {
|
||||
ApplicationDependencies.getJobManager().add(
|
||||
|
|
|
@ -57,7 +57,6 @@ class StorySlateView @JvmOverloads constructor(
|
|||
callback?.onStateChanged(State.HIDDEN, postId)
|
||||
}
|
||||
|
||||
if (this.state.isValidTransitionTo(state)) {
|
||||
when (state) {
|
||||
State.LOADING -> moveToProgressState(State.LOADING)
|
||||
State.ERROR -> moveToErrorState()
|
||||
|
@ -67,9 +66,6 @@ class StorySlateView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
callback?.onStateChanged(state, postId)
|
||||
} else {
|
||||
Log.d(TAG, "Invalid state transfer: ${this.state} -> $state")
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue