From 0b65c59b592131cc51d73f2a57659c9c176e1a0c Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Tue, 13 Dec 2022 21:46:51 +0100 Subject: [PATCH] Ignore favorites errors when updating recipes --- .../mealient/data/recipes/impl/RecipesRemoteMediator.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipesRemoteMediator.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipesRemoteMediator.kt index 32cee67..16f206f 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipesRemoteMediator.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipesRemoteMediator.kt @@ -68,7 +68,9 @@ class RecipesRemoteMediator @Inject constructor( ): Int = coroutineScope { logger.v { "updateRecipes() called with: start = $start, limit = $limit, loadType = $loadType" } 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 entities = withContext(dispatchers.default) { recipes.map { recipe ->