Skip prefetch call if no stories need to be cached.

main
Alex Hart 2022-11-16 09:46:26 -04:00
rodzic ad001d585e
commit 4908e39308
1 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import io.reactivex.rxjava3.subjects.PublishSubject
import io.reactivex.rxjava3.subjects.Subject
import org.thoughtcrime.securesms.attachments.Attachment
import org.thoughtcrime.securesms.database.AttachmentDatabase
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.livedata.Store
@ -87,11 +88,13 @@ class StoryViewerPageViewModel(
)
}
storyCache.prefetch(
posts.map { it.content }
.filterIsInstance<StoryPost.Content.AttachmentContent>()
.map { it.attachment }
)
val attachments: List<Attachment> = posts.map { it.content }
.filterIsInstance<StoryPost.Content.AttachmentContent>()
.map { it.attachment }
if (attachments.isNotEmpty()) {
storyCache.prefetch(attachments)
}
}
disposables += storyLongPressSubject.debounce(150, TimeUnit.MILLISECONDS).subscribe { isLongPress ->