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

DROID-3056 Protocol | Integrate 0.37.0-alpha04 (#1792)

This commit is contained in:
Konstantin Ivanov 2024-11-12 11:05:42 +01:00 committed by GitHub
parent 92ee1b4ce5
commit fbe7242d0f
Signed by: github
GPG key ID: B5690EEEBB952194
7 changed files with 83 additions and 40 deletions

View file

@ -2,6 +2,7 @@ package com.anytypeio.anytype.core_models
data class Process(
val id: String,
val spaceId: Id,
val type: Type,
val state: State,
val progress: Progress?
@ -11,8 +12,8 @@ data class Process(
IMPORT,
EXPORT,
SAVE_FILE,
RECOVER_ACCOUNT,
MIGRATION
MIGRATION,
UNKNOWN
}
enum class State {

View file

@ -1,5 +1,5 @@
[versions]
middlewareVersion = "v0.37.0-alpha03"
middlewareVersion = "v0.37.0-alpha04"
kotlinVersion = '2.0.21'
kspVersion = "2.0.21-1.0.25"

View file

@ -1,6 +1,5 @@
package com.anytypeio.anytype.middleware.interactor
import anytype.Model
import com.anytypeio.anytype.core_models.Process
import com.anytypeio.anytype.data.auth.event.EventProcessDropFilesRemoteChannel
import com.anytypeio.anytype.data.auth.event.EventProcessImportRemoteChannel
@ -24,8 +23,8 @@ class EventProcessDropFilesMiddlewareChannel(
when {
eventProcessNew != null -> {
val process = eventProcessNew.process
val processType = process?.type
if (processType == Model.Process.Type.DropFiles) {
val processType = process?.dropFiles
if (processType != null) {
Process.Event.DropFiles.New(
process = process.toCoreModel()
)
@ -36,8 +35,8 @@ class EventProcessDropFilesMiddlewareChannel(
eventProcessUpdate != null -> {
val process = eventProcessUpdate.process
val processType = process?.type
if (processType == Model.Process.Type.DropFiles) {
val processType = process?.dropFiles
if (processType != null) {
Process.Event.DropFiles.Update(
process = process.toCoreModel()
)
@ -48,8 +47,8 @@ class EventProcessDropFilesMiddlewareChannel(
eventProcessDone != null -> {
val process = eventProcessDone.process
val processType = process?.type
if (processType == Model.Process.Type.DropFiles) {
val processType = process?.dropFiles
if (processType != null) {
Process.Event.DropFiles.Done(
process = process.toCoreModel()
)
@ -80,8 +79,8 @@ class EventProcessImportMiddlewareChannel(
when {
eventProcessNew != null -> {
val process = eventProcessNew.process
val processType = process?.type
if (processType == Model.Process.Type.Import) {
val processType = process?.import_
if (processType != null) {
Process.Event.Import.New(
process = process.toCoreModel()
)
@ -92,8 +91,8 @@ class EventProcessImportMiddlewareChannel(
eventProcessUpdate != null -> {
val process = eventProcessUpdate.process
val processType = process?.type
if (processType == Model.Process.Type.Import) {
val processType = process?.import_
if (processType != null) {
Process.Event.Import.Update(
process = process.toCoreModel()
)
@ -104,8 +103,8 @@ class EventProcessImportMiddlewareChannel(
eventProcessDone != null -> {
val process = eventProcessDone.process
val processType = process?.type
if (processType == Model.Process.Type.Import) {
val processType = process?.import_
if (processType != null) {
Process.Event.Import.Done(
process = process.toCoreModel()
)

View file

@ -86,7 +86,6 @@ typealias MParticipantPermission = anytype.model.ParticipantPermissions
typealias MManifestInfo = anytype.model.ManifestInfo
typealias MProcess = anytype.Model.Process
typealias MProcessType = anytype.Model.Process.Type
typealias MProcessState = anytype.Model.Process.State
typealias MProcessProgress = anytype.Model.Process.Progress

View file

@ -852,25 +852,23 @@ fun MManifestInfo.toCoreModel(): ManifestInfo {
}
fun MProcess.toCoreModel(): Process {
val type = when {
dropFiles != null -> Process.Type.DROP_FILES
import_ != null -> Process.Type.IMPORT
export != null -> Process.Type.EXPORT
saveFile != null -> Process.Type.SAVE_FILE
migration != null -> Process.Type.MIGRATION
else -> Process.Type.UNKNOWN
}
return Process(
id = id,
type = type.toCoreModel(),
type = type,
state = state.toCoreModel(),
progress = progress?.toCoreModel()
progress = progress?.toCoreModel(),
spaceId = spaceId
)
}
fun MProcessType.toCoreModel(): Process.Type {
return when (this) {
MProcessType.DropFiles -> Process.Type.DROP_FILES
MProcessType.Import -> Process.Type.IMPORT
MProcessType.Export -> Process.Type.EXPORT
MProcessType.SaveFile -> Process.Type.SAVE_FILE
MProcessType.RecoverAccount -> Process.Type.RECOVER_ACCOUNT
MProcessType.Migration -> Process.Type.MIGRATION
}
}
fun MProcessState.toCoreModel(): Process.State {
return when (this) {
MProcessState.None -> Process.State.NONE

View file

@ -3119,8 +3119,12 @@ message Rpc {
message Response {
Error error = 1;
repeated string relationKeys = 2;
repeated int64 counters = 3;
repeated ResponseItem list = 2;
message ResponseItem {
string relationKey = 1;
int64 counter = 2;
}
message Error {
Code code = 1;
@ -6703,6 +6707,42 @@ message Rpc {
string id = 1;
}
message Response {
Error error = 1;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
}
}
}
}
message Subscribe {
message Request {}
message Response {
Error error = 1;
message Error {
Code code = 1;
string description = 2;
enum Code {
NULL = 0;
UNKNOWN_ERROR = 1;
BAD_INPUT = 2;
}
}
}
}
message Unsubscribe {
message Request {}
message Response {
Error error = 1;

View file

@ -1160,19 +1160,25 @@ message ResponseEvent {
message Model {
message Process {
string id = 1;
Type type = 2;
State state = 3;
Progress progress = 4;
string spaceId = 5;
enum Type {
DropFiles = 0;
Import = 1;
Export = 2;
SaveFile = 3;
RecoverAccount = 4;
Migration = 5;
oneof message {
DropFiles dropFiles = 6;
Import import= 7;
Export export= 8;
SaveFile saveFile = 9;
Migration migration = 10;
}
string error = 11;
message DropFiles {}
message Import {}
message Export {}
message SaveFile {}
message Migration {}
enum State {
None = 0;
Running = 1;