mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Categories to MainNavVM
This commit is contained in:
parent
1fdc74731e
commit
211ec583c5
@ -226,6 +226,15 @@ interface CategoryDao : BaseDao<Category> {
|
||||
)
|
||||
val allNames: List<String>
|
||||
|
||||
@get:Query(
|
||||
"""SELECT DISTINCT category.name
|
||||
FROM category AS category
|
||||
JOIN repository AS repository
|
||||
ON category.repository_id = repository._id
|
||||
WHERE repository.enabled != 0"""
|
||||
)
|
||||
val allNamesLive: LiveData<List<String>>
|
||||
|
||||
@Query("DELETE FROM category WHERE repository_id = :id")
|
||||
fun deleteById(id: Long): Int
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ class MainNavFragmentViewModelX(
|
||||
val secondaryProducts = MediatorLiveData<List<Product>>()
|
||||
|
||||
val repositories = MediatorLiveData<List<Repository>>()
|
||||
val categories = MediatorLiveData<List<String>>()
|
||||
|
||||
init {
|
||||
primaryProducts.addSource(
|
||||
@ -78,6 +79,7 @@ class MainNavFragmentViewModelX(
|
||||
secondaryProducts::setValue
|
||||
)
|
||||
repositories.addSource(db.repositoryDao.allLive, repositories::setValue)
|
||||
categories.addSource(db.categoryDao.allNamesLive, categories::setValue)
|
||||
}
|
||||
|
||||
fun setSection(newSection: Section) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user