mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3399 Primitives | Provide type relations into Type DataView properties menu (#2262)
This commit is contained in:
parent
770c750eac
commit
bb4e5479e7
22 changed files with 318 additions and 46 deletions
|
@ -1084,4 +1084,8 @@ class BlockMiddleware(
|
|||
override suspend fun objectTypeSetRecommendedFields(command: Command.ObjectTypeSetRecommendedFields) {
|
||||
middleware.objectTypeSetRecommendedFields(command)
|
||||
}
|
||||
|
||||
override suspend fun setDataViewProperties(command: Command.SetDataViewProperties): Payload {
|
||||
return middleware.setDataViewProperties(command)
|
||||
}
|
||||
}
|
|
@ -2934,6 +2934,21 @@ class Middleware @Inject constructor(
|
|||
logResponseIfDebug(response, time)
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun setDataViewProperties(
|
||||
command: Command.SetDataViewProperties
|
||||
): Payload {
|
||||
val request = Rpc.BlockDataview.Relation.Set.Request(
|
||||
contextId = command.objectId,
|
||||
blockId = command.blockId,
|
||||
relationKeys = command.properties
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.blockDataViewRelationSet(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
private fun logRequestIfDebug(request: Any) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
logger.logRequest(request).also {
|
||||
|
|
|
@ -630,4 +630,7 @@ interface MiddlewareService {
|
|||
|
||||
@Throws(Exception::class)
|
||||
fun objectTypeRecommendedFieldsSet(request: Rpc.ObjectType.Recommended.RelationsSet.Request) : Rpc.ObjectType.Recommended.RelationsSet.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun blockDataViewRelationSet(request: Rpc.BlockDataview.Relation.Set.Request): Rpc.BlockDataview.Relation.Set.Response
|
||||
}
|
|
@ -2547,4 +2547,17 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun blockDataViewRelationSet(request: Rpc.BlockDataview.Relation.Set.Request): Rpc.BlockDataview.Relation.Set.Response {
|
||||
val encoded = Service.blockDataviewRelationSet(
|
||||
Rpc.BlockDataview.Relation.Set.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.BlockDataview.Relation.Set.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.BlockDataview.Relation.Set.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue