Pin tags to favorites

This commit is contained in:
MM20
2022-09-23 22:38:44 +02:00
parent 60f36795ab
commit f16e9c2b40
15 changed files with 630 additions and 34 deletions
@@ -10,7 +10,6 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import org.json.JSONArray
import org.json.JSONException
import java.io.File
@@ -32,6 +31,7 @@ interface CustomAttributesRepository {
suspend fun import(fromDir: File)
suspend fun getAllTags(startsWith: String? = null): List<String>
fun getItemsForTag(tag: String): Flow<List<Searchable>>
}
internal class CustomAttributesRepositoryImpl(
@@ -115,6 +115,13 @@ internal class CustomAttributesRepositoryImpl(
}
}
override fun getItemsForTag(tag: String): Flow<List<Searchable>> {
val dao = appDatabase.customAttrsDao()
return dao.getItemsWithTag(tag).map {
favoritesRepository.getFromKeys(it)
}
}
override suspend fun search(query: String): Flow<List<Searchable>> {
if (query.isBlank()) {
return flow {