mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1992 Tech | Objects details refactoring (#1997)
This commit is contained in:
parent
6d37f78dd2
commit
524e15d26e
116 changed files with 2197 additions and 2420 deletions
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.core_models.Event
|
|||
import com.anytypeio.anytype.middleware.BuildConfig
|
||||
import com.anytypeio.anytype.middleware.mappers.MWidgetLayout
|
||||
import com.anytypeio.anytype.middleware.mappers.core
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreFieldsModel
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModel
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModels
|
||||
import com.anytypeio.anytype.middleware.mappers.toCoreModelsAlign
|
||||
|
@ -118,7 +119,7 @@ fun anytype.Event.Message.toCoreModels(
|
|||
Event.Command.UpdateFields(
|
||||
context = context,
|
||||
target = event.id,
|
||||
fields = event.fields.toCoreModel()
|
||||
fields = event.fields.toCoreFieldsModel()
|
||||
)
|
||||
}
|
||||
blockSetFile != null -> {
|
||||
|
|
|
@ -89,11 +89,7 @@ fun MObjectView.toPayload(): Payload {
|
|||
context = rootId,
|
||||
root = rootId,
|
||||
blocks = blocks.toCoreModels(),
|
||||
details = Block.Details(
|
||||
details.associate { details ->
|
||||
details.id to details.details.toCoreModel()
|
||||
}
|
||||
),
|
||||
details = details.associate { d -> d.id to d.details.orEmpty() },
|
||||
objectRestrictions = restrictions?.object_?.map { it.toCoreModel() }.orEmpty(),
|
||||
dataViewRestrictions = restrictions?.dataview?.map { it.toCoreModel() }.orEmpty()
|
||||
)
|
||||
|
@ -299,7 +295,9 @@ fun List<MBlock>.toCoreModels(): List<Block> = mapNotNull { block ->
|
|||
}
|
||||
}
|
||||
|
||||
fun Map<String, *>?.toCoreModel(): Block.Fields = Block.Fields(this?.toMap().orEmpty())
|
||||
fun Map<String, *>?.toCoreFieldsModel(): Block.Fields = Block.Fields(this?.toMap().orEmpty())
|
||||
|
||||
fun Map<String, *>?.toCoreModel(): Map<String, Any?> = this?.toMap().orEmpty()
|
||||
|
||||
fun MBlock.toCoreModelsText(): Block.Content.Text {
|
||||
val content = checkNotNull(text)
|
||||
|
|
|
@ -276,7 +276,7 @@ class MiddlewareEventChannelTest {
|
|||
val icon = Pair("icon", ":package:")
|
||||
val name = Pair("name", "Document I")
|
||||
|
||||
val details = com.anytypeio.anytype.core_models.Block.Fields(map = mutableMapOf(icon, name))
|
||||
val details = mutableMapOf(icon, name)
|
||||
|
||||
val msg = anytype.Event.Object.Details.Set(
|
||||
id = id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue