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

DROID-1650 Templates | Default template for new object creation (#462)

This commit is contained in:
Konstantin Ivanov 2023-10-25 10:00:59 +02:00 committed by GitHub
parent 9e43f5af02
commit ad9bc52e2e
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 367 additions and 284 deletions

View file

@ -864,7 +864,7 @@ class Middleware @Inject constructor(
templateId = command.template.orEmpty(),
internalFlags = command.internalFlags.toMiddlewareModel(),
spaceId = command.space.id,
objectTypeUniqueKey = command.type.key
objectTypeUniqueKey = command.typeKey.key
)
if (BuildConfig.DEBUG) logRequest(request)
val response = service.objectCreate(request)
@ -885,7 +885,8 @@ class Middleware @Inject constructor(
internalFlags = command.internalFlags.toMiddlewareModel(),
targetId = command.target,
position = command.position.toMiddlewareModel(),
fields = null
fields = null,
spaceId = command.space
)
if (BuildConfig.DEBUG) logRequest(request)

View file

@ -27,7 +27,6 @@ import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
typealias CBlock = com.anytypeio.anytype.core_models.Block
typealias CFields = com.anytypeio.anytype.core_models.Block.Fields
typealias CBlockFileType = com.anytypeio.anytype.core_models.Block.Content.File.Type
typealias CBlockPrototypeText = com.anytypeio.anytype.core_models.Block.Prototype.Text
@ -79,6 +78,7 @@ class MiddlewareTest {
// SETUP
val templateId = MockDataFactory.randomUuid()
val spaceId = MockDataFactory.randomUuid()
val typeKey = TypeKey(MockDataFactory.randomUuid())
@ -89,7 +89,8 @@ class MiddlewareTest {
template = templateId,
prefilled = emptyMap(),
internalFlags = listOf(),
type = typeKey
type = typeKey,
space = spaceId
)
val response = Rpc.BlockLink.CreateWithObject.Response(
@ -104,7 +105,8 @@ class MiddlewareTest {
position = Block.Position.Inner,
details = mapOf<String, Any?>(),
templateId = templateId,
objectTypeUniqueKey = typeKey.key
objectTypeUniqueKey = typeKey.key,
spaceId = spaceId
)
service.stub {
@ -136,6 +138,7 @@ class MiddlewareTest {
val name = MockDataFactory.randomString()
val typeKey = TypeKey(MockDataFactory.randomUuid())
val spaceId = MockDataFactory.randomUuid()
val command = Command.CreateBlockLinkWithObject(
context = MockDataFactory.randomUuid(),
@ -144,7 +147,8 @@ class MiddlewareTest {
template = null,
prefilled = buildMap { put(Relations.NAME, name) },
internalFlags = listOf(),
type = typeKey
type = typeKey,
space = spaceId
)
val response = Rpc.BlockLink.CreateWithObject.Response(
@ -158,7 +162,8 @@ class MiddlewareTest {
targetId = command.target,
position = Block.Position.Inner,
details = buildMap { put(Relations.NAME, name) },
objectTypeUniqueKey = typeKey.key
objectTypeUniqueKey = typeKey.key,
spaceId = spaceId
)
service.stub {