From 6f60ef434680c741b9c23445b4dbd3c33508d638 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Fri, 30 Sep 2022 09:11:55 +0200 Subject: [PATCH] Remove unnecessary return value --- .../readerforselfossv2/repository/RepositoryImpl.kt | 7 +++---- .../readerforselfossv2/repository/RepositoryTest.kt | 11 +++-------- 2 files changed, 6 insertions(+), 12 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 c484a26..c96d40b 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 @@ -456,17 +456,16 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap db.itemsQueries.updateItem(item.datetime, item.title.getHtmlDecoded(), item.content, item.unread, item.starred, item.thumbnail, item.icon, item.link, item.sourcetitle, item.tags.joinToString(","), item.id.toString()) // TODO: This function should check for duplicate items - suspend fun tryToCacheItemsAndGetNewOnes(): List { + suspend fun tryToCacheItemsAndGetNewOnes() { try { val newItems = getMaxItemsForBackground(ItemType.UNREAD) val allItems = getMaxItemsForBackground(ItemType.ALL) val starredItems = getMaxItemsForBackground(ItemType.STARRED) - insertDBItems(newItems + allItems + starredItems) - return newItems + val fullItemsList = newItems + allItems + starredItems + insertDBItems(fullItemsList) } catch (e: Throwable) { // We do nothing } - return emptyList() } // TODO: Add tests 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 f6f80ae..2e06685 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 @@ -899,9 +899,8 @@ class RepositoryTest() { "d8c92cdb1ef119ea85c4b9205c879ca7.png" ) repository.searchFilter = "search" - var items = emptyList() runBlocking { - items = repository.tryToCacheItemsAndGetNewOnes() + repository.tryToCacheItemsAndGetNewOnes() } coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } @@ -923,13 +922,11 @@ class RepositoryTest() { "d8c92cdb1ef119ea85c4b9205c879ca7.png" ) repository.searchFilter = "search" - var items = emptyList() runBlocking { - items = repository.tryToCacheItemsAndGetNewOnes() + repository.tryToCacheItemsAndGetNewOnes() } coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } - assertSame(0, items.size) } @Test @@ -949,13 +946,11 @@ class RepositoryTest() { "d8c92cdb1ef119ea85c4b9205c879ca7.png" ) repository.searchFilter = "search" - var items = emptyList() runBlocking { - items = repository.tryToCacheItemsAndGetNewOnes() + repository.tryToCacheItemsAndGetNewOnes() } coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) } - assertSame(emptyList(), items) } }