Tweak search query thresholds
This commit is contained in:
parent
840aa9b4c4
commit
41a0157983
@ -38,7 +38,7 @@ internal class CalendarRepositoryImpl(
|
|||||||
) : CalendarRepository {
|
) : CalendarRepository {
|
||||||
|
|
||||||
override fun search(query: String): Flow<ImmutableList<CalendarEvent>> {
|
override fun search(query: String): Flow<ImmutableList<CalendarEvent>> {
|
||||||
if (query.isBlank() || query.length < 3) {
|
if (query.isBlank() || query.length < 2) {
|
||||||
return flow {
|
return flow {
|
||||||
emit(persistentListOf())
|
emit(persistentListOf())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ internal class ContactRepositoryImpl(
|
|||||||
override fun search(query: String): Flow<ImmutableList<Contact>> {
|
override fun search(query: String): Flow<ImmutableList<Contact>> {
|
||||||
val hasPermission = permissionsManager.hasPermission(PermissionGroup.Contacts)
|
val hasPermission = permissionsManager.hasPermission(PermissionGroup.Contacts)
|
||||||
|
|
||||||
if (query.length < 3) {
|
if (query.length < 2) {
|
||||||
return flow {
|
return flow {
|
||||||
emit(persistentListOf())
|
emit(persistentListOf())
|
||||||
}
|
}
|
||||||
@ -59,6 +59,7 @@ internal class ContactRepositoryImpl(
|
|||||||
val results = mutableListOf<Contact>()
|
val results = mutableListOf<Contact>()
|
||||||
for ((id, rawIds) in contactMap) {
|
for ((id, rawIds) in contactMap) {
|
||||||
Contact.contactById(context, id, rawIds)?.let { results.add(it) }
|
Contact.contactById(context, id, rawIds)?.let { results.add(it) }
|
||||||
|
if (results.size > 15) break
|
||||||
}
|
}
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ internal class LocalFileProvider(
|
|||||||
if (!permissionsManager.checkPermissionOnce(PermissionGroup.ExternalStorage)) {
|
if (!permissionsManager.checkPermissionOnce(PermissionGroup.ExternalStorage)) {
|
||||||
return@withContext emptyList()
|
return@withContext emptyList()
|
||||||
}
|
}
|
||||||
|
if (query.length < 2 || query.isBlank()) return@withContext emptyList()
|
||||||
val results = mutableListOf<LocalFile>()
|
val results = mutableListOf<LocalFile>()
|
||||||
val uri = MediaStore.Files.getContentUri("external").buildUpon()
|
val uri = MediaStore.Files.getContentUri("external").buildUpon()
|
||||||
.appendQueryParameter("limit", "10").build()
|
.appendQueryParameter("limit", "10").build()
|
||||||
@ -29,9 +30,8 @@ internal class LocalFileProvider(
|
|||||||
MediaStore.Files.FileColumns.DATA,
|
MediaStore.Files.FileColumns.DATA,
|
||||||
MediaStore.Files.FileColumns.MIME_TYPE
|
MediaStore.Files.FileColumns.MIME_TYPE
|
||||||
)
|
)
|
||||||
val selection =
|
val selection = "${MediaStore.Files.FileColumns.TITLE} LIKE ?"
|
||||||
if (query.length > 3) "${MediaStore.Files.FileColumns.TITLE} LIKE ?" else "${MediaStore.Files.FileColumns.TITLE} = ?"
|
val selArgs = if (query.length > 3) arrayOf("%$query%") else arrayOf("$query%")
|
||||||
val selArgs = if (query.length > 3) arrayOf("%$query%") else arrayOf(query)
|
|
||||||
val sort = "${MediaStore.Files.FileColumns.DISPLAY_NAME} COLLATE NOCASE ASC"
|
val sort = "${MediaStore.Files.FileColumns.DISPLAY_NAME} COLLATE NOCASE ASC"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -63,6 +63,8 @@ internal class WikipediaRepositoryImpl(
|
|||||||
httpClient.dispatcher.cancelAll()
|
httpClient.dispatcher.cancelAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query.length < 4) return@channelFlow
|
||||||
|
|
||||||
if (!::wikipediaService.isInitialized) return@channelFlow
|
if (!::wikipediaService.isInitialized) return@channelFlow
|
||||||
if (query.isBlank()) return@channelFlow
|
if (query.isBlank()) return@channelFlow
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user