Rearrange filtering steps

This commit is contained in:
davidoskky 2022-10-11 00:52:12 +02:00
parent d0a982f385
commit 02098a7aa9

View File

@ -66,16 +66,19 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
} else { } else {
if (appSettingsService.isItemCachingEnabled()) { if (appSettingsService.isItemCachingEnabled()) {
fromDB = true fromDB = true
val dbItems = getDBItems().filter {
displayedItems == ItemType.ALL ||
(it.unread && displayedItems == ItemType.UNREAD) ||
(it.starred && displayedItems == ItemType.STARRED)
}
if (tagFilter != null) {
dbItems.filter { it.tags.contains(tagFilter!!.tag) }
}
if (sourceFilter != null) {
dbItems.filter { it.sourcetitle == sourceFilter!!.title }
}
fetchedItems = SelfossModel.StatusAndData.succes( fetchedItems = SelfossModel.StatusAndData.succes(
getDBItems().filter { dbItems.map { it.toView() }
displayedItems == ItemType.ALL ||
(it.unread && displayedItems == ItemType.UNREAD) ||
(it.starred && displayedItems == ItemType.STARRED)
}.filter {
tagFilter == null || it.tags.contains(tagFilter!!.tag)
}.filter {
sourceFilter == null || it.sourcetitle == sourceFilter!!.title
}.map { it.toView() }
) )
} }
} }