Remove unnecessary return value

This commit is contained in:
davidoskky 2022-09-30 09:11:55 +02:00
parent 28b950f467
commit 6f60ef4346
2 changed files with 6 additions and 12 deletions

View File

@ -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()) 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 // TODO: This function should check for duplicate items
suspend fun tryToCacheItemsAndGetNewOnes(): List<SelfossModel.Item> { suspend fun tryToCacheItemsAndGetNewOnes() {
try { try {
val newItems = getMaxItemsForBackground(ItemType.UNREAD) val newItems = getMaxItemsForBackground(ItemType.UNREAD)
val allItems = getMaxItemsForBackground(ItemType.ALL) val allItems = getMaxItemsForBackground(ItemType.ALL)
val starredItems = getMaxItemsForBackground(ItemType.STARRED) val starredItems = getMaxItemsForBackground(ItemType.STARRED)
insertDBItems(newItems + allItems + starredItems) val fullItemsList = newItems + allItems + starredItems
return newItems insertDBItems(fullItemsList)
} catch (e: Throwable) { } catch (e: Throwable) {
// We do nothing // We do nothing
} }
return emptyList()
} }
// TODO: Add tests // TODO: Add tests

View File

@ -899,9 +899,8 @@ class RepositoryTest() {
"d8c92cdb1ef119ea85c4b9205c879ca7.png" "d8c92cdb1ef119ea85c4b9205c879ca7.png"
) )
repository.searchFilter = "search" repository.searchFilter = "search"
var items = emptyList<SelfossModel.Item>()
runBlocking { runBlocking {
items = repository.tryToCacheItemsAndGetNewOnes() repository.tryToCacheItemsAndGetNewOnes()
} }
coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) }
@ -923,13 +922,11 @@ class RepositoryTest() {
"d8c92cdb1ef119ea85c4b9205c879ca7.png" "d8c92cdb1ef119ea85c4b9205c879ca7.png"
) )
repository.searchFilter = "search" repository.searchFilter = "search"
var items = emptyList<SelfossModel.Item>()
runBlocking { runBlocking {
items = repository.tryToCacheItemsAndGetNewOnes() repository.tryToCacheItemsAndGetNewOnes()
} }
coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) } coVerify(exactly = 3) { api.getItems(any(), 0, null, null, null, null, 200) }
assertSame(0, items.size)
} }
@Test @Test
@ -949,13 +946,11 @@ class RepositoryTest() {
"d8c92cdb1ef119ea85c4b9205c879ca7.png" "d8c92cdb1ef119ea85c4b9205c879ca7.png"
) )
repository.searchFilter = "search" repository.searchFilter = "search"
var items = emptyList<SelfossModel.Item>()
runBlocking { runBlocking {
items = repository.tryToCacheItemsAndGetNewOnes() repository.tryToCacheItemsAndGetNewOnes()
} }
coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) } coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) }
assertSame(emptyList<SelfossModel.Item>(), items)
} }
} }