From bf8f7d86677ba05145031ceedfa202934cd39dce Mon Sep 17 00:00:00 2001 From: aminecmi Date: Tue, 6 Dec 2022 22:48:30 +0100 Subject: [PATCH] Cleaning. --- .../src/main/res/values-de-rDE/strings.xml | 3 - androidApp/src/test/kotlin/RepositoryTest.kt | 80 +++++++++---------- .../repository/RepositoryImpl.kt | 8 +- 3 files changed, 40 insertions(+), 51 deletions(-) diff --git a/androidApp/src/main/res/values-de-rDE/strings.xml b/androidApp/src/main/res/values-de-rDE/strings.xml index 2711913..3fad23c 100644 --- a/androidApp/src/main/res/values-de-rDE/strings.xml +++ b/androidApp/src/main/res/values-de-rDE/strings.xml @@ -61,11 +61,8 @@ Kartenhöhe passt sich Inhalt an Kartenhöhe ist fix Quellcode - Filter - leeren Tags Quellen - Lade… Suche Can\'t delete the source… Beim Versuch deine Selfoss-Instanz zu erreichen ist ein Fehler aufgetreten. Solltet dieser Fehler bestehen bleiben, trete bitte mit mir in Kontakt. diff --git a/androidApp/src/test/kotlin/RepositoryTest.kt b/androidApp/src/test/kotlin/RepositoryTest.kt index d666a50..3425b0e 100644 --- a/androidApp/src/test/kotlin/RepositoryTest.kt +++ b/androidApp/src/test/kotlin/RepositoryTest.kt @@ -196,7 +196,7 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Test", "red", 3)) + repository.setTagFilter(SelfossModel.Tag("Test", "red", 3)) runBlocking { repository.getNewerItems() } @@ -224,16 +224,14 @@ class RepositoryTest { every { appSettingsService.isItemCachingEnabled() } returns true initializeRepository(MutableStateFlow(false)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "Test", - listOf("tags"), - "spouts\\rss\\fulltextrss", - "", - "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" - ) - ) + repository.setSourceFilter(SelfossModel.Source( + 1, + "Test", + listOf("tags"), + "spouts\\rss\\fulltextrss", + "", + "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" + )) runBlocking { repository.getNewerItems() } @@ -1304,17 +1302,15 @@ class RepositoryTest { ) initializeRepository() - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() @@ -1329,17 +1325,15 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository() - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() @@ -1354,17 +1348,15 @@ class RepositoryTest { StatusAndData(success = false, data = generateTestApiItem()) initializeRepository(MutableStateFlow(false)) - repository.tagFilter = MutableStateFlow(SelfossModel.Tag("Tag", "read", 0)) - repository.sourceFilter = MutableStateFlow( - SelfossModel.Source( - 1, - "First source", - listOf("Test", "second"), - "spouts\\rss\\fulltextrss", - "", - "d8c92cdb1ef119ea85c4b9205c879ca7.png" - ) - ) + repository.setTagFilter(SelfossModel.Tag("Tag", "read", 0)) + repository.setSourceFilter(SelfossModel.Source( + 1, + "First source", + listOf("Test", "second"), + "spouts\\rss\\fulltextrss", + "", + "d8c92cdb1ef119ea85c4b9205c879ca7.png" + )) repository.searchFilter = "search" runBlocking { repository.tryToCacheItemsAndGetNewOnes() 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 a48a9c7..48ab99f 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 @@ -62,11 +62,11 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap (it.unread && displayedItems == ItemType.UNREAD) || (it.starred && displayedItems == ItemType.STARRED) } - if (tagFilter != null) { - dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value?.tag) } + if (tagFilter.value != null) { + dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value!!.tag) } } - if (sourceFilter != null) { - dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value?.title } + if (sourceFilter.value != null) { + dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value!!.title } } fetchedItems = StatusAndData.succes( dbItems.map { it.toView() }