Filters working.
This commit is contained in:
@ -23,8 +23,10 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
|
||||
var displayedItems = ItemType.UNREAD
|
||||
|
||||
var tagFilter: SelfossModel.Tag? = null
|
||||
var sourceFilter: SelfossModel.Source? = null
|
||||
private var _tagFilter = MutableStateFlow<SelfossModel.Tag?>(null)
|
||||
var tagFilter = _tagFilter.asStateFlow()
|
||||
private var _sourceFilter = MutableStateFlow<SelfossModel.Source?>(null)
|
||||
var sourceFilter = _sourceFilter.asStateFlow()
|
||||
var searchFilter: String? = null
|
||||
|
||||
var offlineOverride = false
|
||||
@ -47,8 +49,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
fetchedItems = api.getItems(
|
||||
displayedItems.type,
|
||||
offset = 0,
|
||||
tagFilter?.tag,
|
||||
sourceFilter?.id?.toLong(),
|
||||
tagFilter.value?.tag,
|
||||
sourceFilter.value?.id?.toLong(),
|
||||
searchFilter,
|
||||
null
|
||||
)
|
||||
@ -61,10 +63,10 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
(it.starred && displayedItems == ItemType.STARRED)
|
||||
}
|
||||
if (tagFilter != null) {
|
||||
dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter!!.tag) }
|
||||
dbItems = dbItems.filter { it.tags.split(',').contains(tagFilter.value?.tag) }
|
||||
}
|
||||
if (sourceFilter != null) {
|
||||
dbItems = dbItems.filter { it.sourcetitle == sourceFilter!!.title }
|
||||
dbItems = dbItems.filter { it.sourcetitle == sourceFilter.value?.title }
|
||||
}
|
||||
fetchedItems = StatusAndData.succes(
|
||||
dbItems.map { it.toView() }
|
||||
@ -88,8 +90,8 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
fetchedItems = api.getItems(
|
||||
displayedItems.type,
|
||||
offset,
|
||||
tagFilter?.tag,
|
||||
sourceFilter?.id?.toLong(),
|
||||
tagFilter.value?.tag,
|
||||
sourceFilter.value?.id?.toLong(),
|
||||
searchFilter,
|
||||
null
|
||||
)
|
||||
@ -505,4 +507,12 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
deleteDBAction(action)
|
||||
}
|
||||
}
|
||||
|
||||
fun setTagFilter(tag: SelfossModel.Tag?) {
|
||||
_tagFilter.value = tag
|
||||
}
|
||||
|
||||
fun setSourceFilter(source: SelfossModel.Source?) {
|
||||
_sourceFilter.value = source
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user