1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-3438 Widgets | Enhancement | Creating widgets with suggest object type (#2216)

This commit is contained in:
Evgenii Kozlov 2025-04-01 08:56:08 +02:00 committed by GitHub
parent 37c4327fa0
commit 7bec1556cb
Signed by: github
GPG key ID: B5690EEEBB952194
12 changed files with 273 additions and 152 deletions

View file

@ -0,0 +1,42 @@
package com.anytypeio.anytype.domain.widgets
import com.anytypeio.anytype.core_models.DVFilter
import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.core_models.ObjectWrapper
import com.anytypeio.anytype.core_models.primitives.Space
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.base.ResultInteractor
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import javax.inject.Inject
class GetSuggestedWidgetTypes @Inject constructor(
dispatchers: AppCoroutineDispatchers,
private val repo: BlockRepository,
) : ResultInteractor<GetSuggestedWidgetTypes.Params, List<ObjectWrapper.Type>>(dispatchers.io) {
override suspend fun doWork(params: Params): List<ObjectWrapper.Type> {
// TODO DROID-3438 open widget object preview and filter out existing object types
val types = repo.searchObjects(
space = params.space,
limit = DEFAULT_LIMIT,
filters = params.objectTypeFilters,
keys = params.objectTypeKeys
).map { result ->
ObjectWrapper.Type(result)
}
return types
}
data class Params(
val space: Space,
val objectTypeFilters: List<DVFilter>,
val objectTypeKeys: List<Id>
)
companion object {
const val DEFAULT_LIMIT = 5
}
}