mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Tech | Refact | Optimize object search by providing keys (#2095)
This commit is contained in:
parent
fa1d9aa0d2
commit
2a4191ce95
14 changed files with 38 additions and 18 deletions
|
@ -16,6 +16,7 @@
|
|||
* Editor | Incorrect numbers in numbered lists when there are nested lists or blocks are grouped by sections (#2072)
|
||||
* Dashboard | Removal from favorites is not synced correctly (#2075)
|
||||
* Sets | Enabled auto-correct when setting name for a new object (#2067)
|
||||
* Search | Optimized object search (#2095)
|
||||
|
||||
### Design & UX 🔳
|
||||
|
||||
|
|
|
@ -415,13 +415,15 @@ class BlockDataRepository(
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>> = factory.remote.searchObjects(
|
||||
sorts = sorts,
|
||||
filters = filters,
|
||||
fulltext = fulltext,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
limit = limit,
|
||||
keys = keys
|
||||
)
|
||||
|
||||
override suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -141,7 +141,8 @@ interface BlockDataStore {
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>>
|
||||
|
||||
suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -147,7 +147,8 @@ interface BlockRemote {
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>>
|
||||
|
||||
suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -329,13 +329,15 @@ class BlockRemoteDataStore(private val remote: BlockRemote) : BlockDataStore {
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>> = remote.searchObjects(
|
||||
sorts = sorts,
|
||||
filters = filters,
|
||||
fulltext = fulltext,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
limit = limit,
|
||||
keys = keys
|
||||
)
|
||||
|
||||
override suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -194,7 +194,8 @@ interface BlockRepository {
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id> = emptyList()
|
||||
): List<Map<String, Any?>>
|
||||
|
||||
suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.anytypeio.anytype.domain.dataview.interactor
|
|||
|
||||
import com.anytypeio.anytype.core_models.DVFilter
|
||||
import com.anytypeio.anytype.core_models.DVSort
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
|
@ -16,7 +17,8 @@ class SearchObjects(
|
|||
filters = params.filters,
|
||||
fulltext = params.fulltext,
|
||||
offset = params.offset,
|
||||
limit = params.limit
|
||||
limit = params.limit,
|
||||
keys = params.keys
|
||||
).map { response ->
|
||||
ObjectWrapper.Basic(response)
|
||||
}
|
||||
|
@ -27,7 +29,8 @@ class SearchObjects(
|
|||
val filters: List<DVFilter> = emptyList(),
|
||||
val fulltext: String = EMPTY_TEXT,
|
||||
val offset: Int = INIT_OFFSET,
|
||||
val limit: Int = LIMIT
|
||||
val limit: Int = LIMIT,
|
||||
val keys: List<Id> = emptyList()
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -355,13 +355,15 @@ class BlockMiddleware(
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>> = middleware.searchObjects(
|
||||
sorts = sorts,
|
||||
filters = filters,
|
||||
fulltext = fulltext,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
limit = limit,
|
||||
keys = keys
|
||||
)
|
||||
|
||||
override suspend fun searchObjectsWithSubscription(
|
||||
|
|
|
@ -1199,14 +1199,16 @@ class Middleware(
|
|||
filters: List<DVFilter>,
|
||||
fulltext: String,
|
||||
offset: Int,
|
||||
limit: Int
|
||||
limit: Int,
|
||||
keys: List<Id>
|
||||
): List<Map<String, Any?>> {
|
||||
val request = Rpc.Object.Search.Request(
|
||||
sorts = sorts.map { it.toMiddlewareModel() },
|
||||
filters = filters.map { it.toMiddlewareModel() },
|
||||
fullText = fulltext,
|
||||
offset = offset,
|
||||
limit = limit
|
||||
limit = limit,
|
||||
keys = keys
|
||||
)
|
||||
if (BuildConfig.DEBUG) logRequest(request)
|
||||
val response = service.objectSearch(request)
|
||||
|
|
|
@ -5216,7 +5216,8 @@ class EditorViewModel(
|
|||
limit = ObjectSearchViewModel.SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterLinkTo,
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = filter.removePrefix(MENTION_PREFIX)
|
||||
fulltext = filter.removePrefix(MENTION_PREFIX),
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
)
|
||||
viewModelScope.launch {
|
||||
searchObjects(params).process(
|
||||
|
|
|
@ -32,7 +32,8 @@ class LinkToObjectViewModel(
|
|||
limit = SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterLinkTo,
|
||||
sorts = ObjectSearchConstants.sortLinkTo,
|
||||
fulltext = EMPTY_QUERY
|
||||
fulltext = EMPTY_QUERY,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
)
|
||||
|
||||
override fun onObjectClicked(target: Id, layout: ObjectType.Layout?) {
|
||||
|
|
|
@ -96,7 +96,8 @@ class MoveToViewModel(
|
|||
limit = SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterMoveTo(filteredTypes),
|
||||
sorts = ObjectSearchConstants.sortMoveTo,
|
||||
fulltext = EMPTY_QUERY
|
||||
fulltext = EMPTY_QUERY,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,8 @@ class RelationObjectValueAddViewModel(
|
|||
filters = filters,
|
||||
fulltext = SearchObjects.EMPTY_TEXT,
|
||||
offset = SearchObjects.INIT_OFFSET,
|
||||
limit = SearchObjects.LIMIT
|
||||
limit = SearchObjects.LIMIT,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
)
|
||||
).process(
|
||||
failure = { Timber.e(it, "Error while getting objects") },
|
||||
|
|
|
@ -73,7 +73,8 @@ open class ObjectSearchViewModel(
|
|||
limit = SEARCH_LIMIT,
|
||||
filters = ObjectSearchConstants.filterSearchObjects,
|
||||
sorts = ObjectSearchConstants.sortsSearchObjects,
|
||||
fulltext = EMPTY_QUERY
|
||||
fulltext = EMPTY_QUERY,
|
||||
keys = ObjectSearchConstants.defaultKeys
|
||||
)
|
||||
|
||||
private fun startProcessingSearchQuery() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue