Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-01 12:50:54 +05:00
parent c71641b451
commit a1bce4b52c

View file

@ -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)