diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index cc2d700..541425c 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -143,13 +143,13 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap return success } - suspend fun getTags(): List? { + suspend fun getTags(): List { return if (isNetworkAvailable()) { val apiTags = api.tags() if (apiTags.success && apiTags.data != null && (appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled())) { resetDBTagsWithData(apiTags.data) } - apiTags.data + apiTags.data ?: emptyList() } else { getDBTags().map { it.toView() } } diff --git a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt index 3114cfc..f4ce3e1 100644 --- a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt +++ b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt @@ -285,7 +285,7 @@ class RepositoryTest() { assertSame(true, success) assertSame(1, repository.badgeAll) - assertSame(0, repository.badgeUnread) + assertSame(1, repository.badgeUnread) assertSame(1, repository.badgeStarred) coVerify(exactly = 0) { api.stats() } verify(atLeast = 1) { db.itemsQueries.items().executeAsList()} @@ -391,13 +391,13 @@ class RepositoryTest() { every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) val repository = Repository(api, appSettingsService, connectivityStatus, db) - var testTags: List? = null + var testTags: List = emptyList() runBlocking { testTags = repository.getTags() } assertNotSame(tags, testTags) - assertSame(tagsDB.first().name, testTags?.first()?.tag) + assertSame(tagsDB.first().name, testTags.first().tag) coVerify(exactly = 0) { api.tags() } verify(atLeast = 1) { db.tagsQueries.tags().executeAsList() } }