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

DROID-3557 Migration | Enhancement | Add process progress to migration screen (#2279)

This commit is contained in:
Evgenii Kozlov 2025-04-10 15:51:34 +02:00 committed by GitHub
parent 4a3a4947c5
commit 338706ff52
Signed by: github
GPG key ID: B5690EEEBB952194
15 changed files with 430 additions and 32 deletions

View file

@ -3,8 +3,10 @@ package com.anytypeio.anytype.middleware.interactor
import com.anytypeio.anytype.core_models.Process
import com.anytypeio.anytype.data.auth.event.EventProcessDropFilesRemoteChannel
import com.anytypeio.anytype.data.auth.event.EventProcessImportRemoteChannel
import com.anytypeio.anytype.data.auth.event.EventProcessMigrationRemoteChannel
import com.anytypeio.anytype.middleware.EventProxy
import com.anytypeio.anytype.middleware.mappers.toCoreModel
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.mapNotNull
@ -113,6 +115,59 @@ class EventProcessImportMiddlewareChannel(
}
}
else -> null
}
}
}
}
}
class EventProcessMigrationMiddlewareChannel @Inject constructor(
private val events: EventProxy
) : EventProcessMigrationRemoteChannel {
override fun observe(): Flow<List<Process.Event.Migration>> {
return events.flow()
.mapNotNull { emission ->
emission.messages.mapNotNull { message ->
val eventProcessNew = message.processNew
val eventProcessUpdate = message.processUpdate
val eventProcessDone = message.processDone
when {
eventProcessNew != null -> {
val process = eventProcessNew.process
val processType = process?.migration
if (processType != null) {
Process.Event.Migration.New(
process = process.toCoreModel()
)
} else {
null
}
}
eventProcessUpdate != null -> {
val process = eventProcessUpdate.process
val processType = process?.migration
if (processType != null) {
Process.Event.Migration.Update(
process = process.toCoreModel()
)
} else {
null
}
}
eventProcessDone != null -> {
val process = eventProcessDone.process
val processType = process?.migration
if (processType != null) {
Process.Event.Migration.Done(
process = process.toCoreModel()
)
} else {
null
}
}
else -> null
}
}