From 8dc3d319cd34902581842bfdb43d11d08cefd20f Mon Sep 17 00:00:00 2001 From: davidoskky Date: Fri, 30 Sep 2022 11:59:08 +0200 Subject: [PATCH] Cleanup --- .../bou/amine/apps/readerforselfossv2/android/HomeActivity.kt | 1 + .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 4 +--- .../apps/readerforselfossv2/repository/RepositoryTest.kt | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt index 87828ad..29c7835 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/HomeActivity.kt @@ -355,6 +355,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar val drawerData = DrawerData(repository.getDBTags().map { it.toView() }, repository.getDBSources().map { it.toView() }) runOnUiThread { + // TODO: All this logic should be handled by the repository, simplify and remove direct DB access // Only refresh if there is no data in the DB, or if the `UpdateSources` setting is enabled if (drawerData.sources?.isEmpty() == true || appSettingsService.isUpdateSourcesEnabled()) { drawerApiCalls(drawerData) 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 7b1cea2..61222f6 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 @@ -391,8 +391,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap api.refreshLoginInformation() } - // TODO: This should be private - suspend fun updateApiVersion() { + private suspend fun updateApiVersion() { val apiMajorVersion = appSettingsService.getApiVersion() if (isNetworkAvailable()) { @@ -453,7 +452,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap private fun updateDBItem(item: SelfossModel.Item) = 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 { try { val newItems = getMaxItemsForBackground(ItemType.UNREAD) 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 2e06685..1d99897 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 @@ -874,7 +874,6 @@ class RepositoryTest() { coVerify(exactly = 1) {appSettingsService.refreshLoginInformation("https://test.com/selfoss/", "login", "password")} } - // TODO: This function should check if duplicate items are added to the database @Test fun `cache items`() { val itemParameter1 = FakeItemParameters()