From cb4f2f02ef07b0b7b96783f5b8ebf5c919ff838b Mon Sep 17 00:00:00 2001 From: davidoskky Date: Tue, 27 Sep 2022 23:26:44 +0200 Subject: [PATCH] Fix repository.tags() returning null --- .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 4 ++-- .../apps/readerforselfossv2/repository/RepositoryTest.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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() } }