mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3476 Migration | Enhancement | Show required space for "Not enough space" error (#2201)
Co-authored-by: Konstantin Ivanov <54908981+konstantiniiv@users.noreply.github.com>
This commit is contained in:
parent
82ac6e47ec
commit
68eff667fb
5 changed files with 12 additions and 11 deletions
|
@ -303,8 +303,8 @@ fun MigrationFailedScreen(
|
|||
onRetryClicked: () -> Unit
|
||||
) {
|
||||
val description = when(state) {
|
||||
MigrationHelperDelegate.State.Failed.NotEnoughSpace -> {
|
||||
stringResource(R.string.migration_error_please_free_up_space_and_run_the_process_again)
|
||||
is MigrationHelperDelegate.State.Failed.NotEnoughSpace -> {
|
||||
stringResource(R.string.migration_error_please_free_up_space_and_run_the_process_again, state.requiredSpaceInMegabytes)
|
||||
}
|
||||
is MigrationHelperDelegate.State.Failed.UnknownError -> {
|
||||
state.error.message ?: stringResource(R.string.unknown_error)
|
||||
|
@ -382,7 +382,7 @@ fun MigrationInProgressScreenPreview() {
|
|||
@Composable
|
||||
fun MigrationFailedScreenPreview() {
|
||||
MigrationFailedScreen(
|
||||
state = MigrationHelperDelegate.State.Failed.NotEnoughSpace,
|
||||
state = MigrationHelperDelegate.State.Failed.NotEnoughSpace(450),
|
||||
onRetryClicked = {}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,5 +5,5 @@ class NeedToUpdateApplicationException: Exception()
|
|||
class AccountMigrationNeededException: Exception()
|
||||
|
||||
sealed class MigrationFailedException : Exception() {
|
||||
class NotEnoughSpace : MigrationFailedException()
|
||||
data class NotEnoughSpace(val requiredSpaceInBytes: Long) : MigrationFailedException()
|
||||
}
|
|
@ -1922,7 +1922,7 @@ Please provide specific details of your needs here.</string>
|
|||
<string name="migration_this_shouldn_t_take_long">This may take some time. Please don’t close the app until the process is complete.</string>
|
||||
<string name="migration_error_try_again">Try again</string>
|
||||
<string name="migration_migration_failed">Migration failed</string>
|
||||
<string name="migration_error_please_free_up_space_and_run_the_process_again">Please free up space and run the process again.</string>
|
||||
<string name="migration_error_please_free_up_space_and_run_the_process_again">Please clear ≈ %1$s MB of space and run the process again</string>
|
||||
|
||||
<string name="fields_screen_title">Properties</string>
|
||||
<string name="field_text_title">Text</string>
|
||||
|
|
|
@ -116,7 +116,7 @@ class MiddlewareServiceImplementation @Inject constructor(
|
|||
if (error != null && error.code != Rpc.Account.Migrate.Response.Error.Code.NULL) {
|
||||
when(error.code) {
|
||||
Rpc.Account.Migrate.Response.Error.Code.NOT_ENOUGH_FREE_SPACE -> {
|
||||
throw MigrationFailedException.NotEnoughSpace()
|
||||
throw MigrationFailedException.NotEnoughSpace(error.requiredSpace)
|
||||
}
|
||||
else -> throw Exception(error.description)
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@ import com.anytypeio.anytype.domain.auth.interactor.MigrateAccount
|
|||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.base.Resultat
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
|
@ -26,8 +24,11 @@ interface MigrationHelperDelegate {
|
|||
.map { result ->
|
||||
when(result) {
|
||||
is Resultat.Failure -> {
|
||||
if (result.exception is MigrationFailedException.NotEnoughSpace) {
|
||||
State.Failed.NotEnoughSpace
|
||||
val exception = result.exception
|
||||
if (exception is MigrationFailedException.NotEnoughSpace) {
|
||||
State.Failed.NotEnoughSpace(
|
||||
requiredSpaceInMegabytes = (exception.requiredSpaceInBytes / 1_048_576)
|
||||
)
|
||||
} else {
|
||||
State.Failed.UnknownError(result.exception)
|
||||
}
|
||||
|
@ -45,7 +46,7 @@ interface MigrationHelperDelegate {
|
|||
data object InProgress : State()
|
||||
sealed class Failed : State() {
|
||||
data class UnknownError(val error: Throwable) : Failed()
|
||||
data object NotEnoughSpace : Failed()
|
||||
data class NotEnoughSpace(val requiredSpaceInMegabytes: Long) : Failed()
|
||||
}
|
||||
data object Migrated : State()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue