Updated on 2026-08-14
This commit is contained in:
parent
c71641b451
commit
a1bce4b52c
1 changed files with 18 additions and 14 deletions
|
|
@ -377,22 +377,26 @@ internal class MainViewModel @Inject constructor(
|
|||
private fun preloadImages() {
|
||||
try {
|
||||
viewModelScope.launch {
|
||||
val swapStories = getStoryContentUseCase.invokeSync(
|
||||
getStoryContentUseCase.invokeSync(
|
||||
id = StoryContentIds.STORY_FIRST_TIME_SWAP.id,
|
||||
refresh = true,
|
||||
).getOrNull()
|
||||
|
||||
if (swapStories == null) {
|
||||
analyticsEventHandler.send(
|
||||
StoriesEvents.Error(
|
||||
type = StoryContentIds.STORY_FIRST_TIME_SWAP.analyticType,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val storiesImages = swapStories.getImageUrls()
|
||||
// try to preload images for stories
|
||||
storiesImages.forEach(imagePreloader::preload)
|
||||
}
|
||||
).fold(
|
||||
ifLeft = { error ->
|
||||
Timber.e(error)
|
||||
analyticsEventHandler.send(
|
||||
StoriesEvents.Error(
|
||||
type = StoryContentIds.STORY_FIRST_TIME_SWAP.analyticType,
|
||||
),
|
||||
)
|
||||
},
|
||||
ifRight = { swapStories ->
|
||||
if (swapStories != null) {
|
||||
val storiesImages = swapStories.getImageUrls()
|
||||
// try to preload images for stories
|
||||
storiesImages.forEach(imagePreloader::preload)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue