Ignore favorites errors when updating recipes

This commit is contained in:
Kirill Kamakin
2022-12-13 21:46:51 +01:00
parent 700614427c
commit 0b65c59b59

View File

@@ -68,7 +68,9 @@ class RecipesRemoteMediator @Inject constructor(
): Int = coroutineScope { ): Int = coroutineScope {
logger.v { "updateRecipes() called with: start = $start, limit = $limit, loadType = $loadType" } logger.v { "updateRecipes() called with: start = $start, limit = $limit, loadType = $loadType" }
val deferredRecipes = async { network.requestRecipes(start, limit) } val deferredRecipes = async { network.requestRecipes(start, limit) }
val favorites = network.getFavoriteRecipes().toHashSet() val favorites = runCatchingExceptCancel {
network.getFavoriteRecipes()
}.getOrDefault(emptyList()).toHashSet()
val recipes = deferredRecipes.await() val recipes = deferredRecipes.await()
val entities = withContext(dispatchers.default) { val entities = withContext(dispatchers.default) {
recipes.map { recipe -> recipes.map { recipe ->