Cleaning.

This commit is contained in:
aminecmi 2022-12-06 22:48:30 +01:00
parent 89c570f34f
commit bf8f7d8667
3 changed files with 40 additions and 51 deletions

View File

@ -61,11 +61,8 @@
<string name="card_height_on">Kartenhöhe passt sich Inhalt an</string>
<string name="card_height_off">Kartenhöhe ist fix</string>
<string name="source_code">Quellcode</string>
<string name="drawer_item_filters">Filter</string>
<string name="drawer_action_clear">leeren</string>
<string name="filter_item_tags">Tags</string>
<string name="filter_item_sources">Quellen</string>
<string name="drawer_loading">Lade…</string>
<string name="menu_home_search">Suche</string>
<string name="can_delete_source">Can\'t delete the source…</string>
<string name="base_url_error">Beim Versuch deine Selfoss-Instanz zu erreichen ist ein Fehler aufgetreten. Solltet dieser Fehler bestehen bleiben, trete bitte mit mir in Kontakt.</string>

View File

@ -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(
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(
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(
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(
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()

View File

@ -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() }