mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2793 Date as an Object | Epic (#1782)
Co-authored-by: Evgenii Kozlov <enklave.mare.balticum@protonmail.com> Co-authored-by: Evgenii Kozlov <ubuphobos@gmail.com>
This commit is contained in:
parent
2b40f21910
commit
ca8721b725
284 changed files with 6589 additions and 1211 deletions
|
@ -21,6 +21,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationListWithValueItem
|
||||
import com.anytypeio.anytype.core_models.Response
|
||||
import com.anytypeio.anytype.core_models.SearchResult
|
||||
import com.anytypeio.anytype.core_models.Struct
|
||||
|
@ -1062,7 +1063,15 @@ class BlockMiddleware(
|
|||
return middleware.dataViewSetActiveView(command)
|
||||
}
|
||||
|
||||
override suspend fun objectRelationListWithValue(command: Command.RelationListWithValue): List<RelationListWithValueItem> {
|
||||
return middleware.objectRelationListWithValue(command)
|
||||
}
|
||||
|
||||
override suspend fun debugAccountSelectTrace(dir: String): String {
|
||||
return middleware.debugAccountSelectTrace(dir)
|
||||
}
|
||||
|
||||
override suspend fun objectDateByTimestamp(command: Command.ObjectDateByTimestamp): Struct? {
|
||||
return middleware.objectDateByTimestamp(command)
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ import com.anytypeio.anytype.core_models.ObjectWrapper
|
|||
import com.anytypeio.anytype.core_models.Payload
|
||||
import com.anytypeio.anytype.core_models.Position
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationListWithValueItem
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.Response
|
||||
import com.anytypeio.anytype.core_models.SearchResult
|
||||
|
@ -1159,6 +1160,18 @@ class Middleware @Inject constructor(
|
|||
return response.event.toPayload()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationListWithValue(command: Command.RelationListWithValue): List<RelationListWithValueItem> {
|
||||
val request = Rpc.Relation.ListWithValue.Request(
|
||||
spaceId = command.space.id,
|
||||
value_ = command.value
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.objectRelationListWithValue(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
return response.list.map { it.toCoreModel() }
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationRemoveFeatured(
|
||||
ctx: Id,
|
||||
|
@ -2828,6 +2841,18 @@ class Middleware @Inject constructor(
|
|||
return response.path
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectDateByTimestamp(command: Command.ObjectDateByTimestamp): Struct? {
|
||||
val request = Rpc.Object.DateByTimestamp.Request(
|
||||
timestamp = command.timestamp,
|
||||
spaceId = command.space.id
|
||||
)
|
||||
logRequestIfDebug(request)
|
||||
val (response, time) = measureTimedValue { service.objectDateByTimestamp(request) }
|
||||
logResponseIfDebug(response, time)
|
||||
return response.details
|
||||
}
|
||||
|
||||
private fun logRequestIfDebug(request: Any) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
logger.logRequest(request).also {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.anytypeio.anytype.middleware.mappers
|
|||
import anytype.ResponseEvent
|
||||
import anytype.Rpc
|
||||
import anytype.model.Account
|
||||
import anytype.model.Import
|
||||
import anytype.model.NameserviceNameType
|
||||
import anytype.model.ParticipantPermissions
|
||||
import anytype.model.Restrictions
|
||||
|
@ -44,7 +43,9 @@ import com.anytypeio.anytype.core_models.Process
|
|||
import com.anytypeio.anytype.core_models.Relation
|
||||
import com.anytypeio.anytype.core_models.RelationFormat
|
||||
import com.anytypeio.anytype.core_models.RelationLink
|
||||
import com.anytypeio.anytype.core_models.RelationListWithValueItem
|
||||
import com.anytypeio.anytype.core_models.SpaceUsage
|
||||
import com.anytypeio.anytype.core_models.TimeInSeconds
|
||||
import com.anytypeio.anytype.core_models.chats.Chat
|
||||
import com.anytypeio.anytype.core_models.history.DiffVersionResponse
|
||||
import com.anytypeio.anytype.core_models.history.ShowVersionResponse
|
||||
|
@ -60,8 +61,9 @@ import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
|||
import com.anytypeio.anytype.core_models.multiplayer.SpaceSyncError
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceSyncNetwork
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceSyncStatus
|
||||
import com.anytypeio.anytype.core_models.primitives.RelationKey
|
||||
import com.anytypeio.anytype.core_models.primitives.SpaceId
|
||||
import com.anytypeio.anytype.core_models.primitives.TimeInSeconds
|
||||
import com.anytypeio.anytype.core_models.primitives.TimestampInSeconds
|
||||
import com.anytypeio.anytype.core_models.restrictions.DataViewRestriction
|
||||
import com.anytypeio.anytype.core_models.restrictions.DataViewRestrictions
|
||||
import com.anytypeio.anytype.core_models.restrictions.ObjectRestriction
|
||||
|
@ -1150,7 +1152,7 @@ fun Rpc.History.Version.toCoreModel(): Version {
|
|||
previousIds = previousIds,
|
||||
spaceMember = authorId,
|
||||
spaceMemberName = authorName,
|
||||
timestamp = TimeInSeconds(time),
|
||||
timestamp = TimestampInSeconds(time),
|
||||
groupId = groupId
|
||||
)
|
||||
}
|
||||
|
@ -1170,4 +1172,11 @@ fun Rpc.History.DiffVersions.Response.toCoreModel(
|
|||
historyEvents = historyEvents.mapNotNull { it.toCoreModels(context) },
|
||||
objectView = objectView?.toCore()
|
||||
)
|
||||
}
|
||||
|
||||
fun Rpc.Relation.ListWithValue.Response.ResponseItem.toCoreModel(): RelationListWithValueItem {
|
||||
return RelationListWithValueItem(
|
||||
key = RelationKey(key = relationKey),
|
||||
counter = counter
|
||||
)
|
||||
}
|
|
@ -156,6 +156,9 @@ interface MiddlewareService {
|
|||
@Throws(Exception::class)
|
||||
fun createTemplateFromObject(request: Rpc.Template.CreateFromObject.Request): Rpc.Template.CreateFromObject.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectDateByTimestamp(request: Rpc.Object.DateByTimestamp.Request): Rpc.Object.DateByTimestamp.Response
|
||||
|
||||
//endregion
|
||||
|
||||
//region OBJECT'S RELATIONS command
|
||||
|
@ -175,6 +178,9 @@ interface MiddlewareService {
|
|||
@Throws(Exception::class)
|
||||
fun objectRelationListAvailable(request: Rpc.ObjectRelation.ListAvailable.Request): Rpc.ObjectRelation.ListAvailable.Response
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun objectRelationListWithValue(request: Rpc.Relation.ListWithValue.Request): Rpc.Relation.ListWithValue.Response
|
||||
|
||||
// @Throws(Exception::class)
|
||||
// fun objectRelationOptionAdd(request: Rpc.ObjectRelationOption.Add.Request): Rpc.ObjectRelationOption.Add.Response
|
||||
|
||||
|
|
|
@ -961,6 +961,19 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun objectRelationListWithValue(request: Rpc.Relation.ListWithValue.Request): Rpc.Relation.ListWithValue.Response {
|
||||
val encoded = Service.relationListWithValue(
|
||||
Rpc.Relation.ListWithValue.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.Relation.ListWithValue.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.Relation.ListWithValue.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun objectRelationRemoveFeatured(request: Rpc.ObjectRelation.RemoveFeatured.Request): Rpc.ObjectRelation.RemoveFeatured.Response {
|
||||
val encoded = Service.objectRelationRemoveFeatured(
|
||||
Rpc.ObjectRelation.RemoveFeatured.Request.ADAPTER.encode(request)
|
||||
|
@ -2424,4 +2437,17 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
return response
|
||||
}
|
||||
}
|
||||
|
||||
override fun objectDateByTimestamp(request: Rpc.Object.DateByTimestamp.Request): Rpc.Object.DateByTimestamp.Response {
|
||||
val encoded = Service.objectDateByTimestamp(
|
||||
Rpc.Object.DateByTimestamp.Request.ADAPTER.encode(request)
|
||||
)
|
||||
val response = Rpc.Object.DateByTimestamp.Response.ADAPTER.decode(encoded)
|
||||
val error = response.error
|
||||
if (error != null && error.code != Rpc.Object.DateByTimestamp.Response.Error.Code.NULL) {
|
||||
throw Exception(error.description)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue