From 3cd15bc08173ea5a919127df13e6e474f8b68f84 Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Tue, 1 Jul 2025 20:57:20 +0200 Subject: [PATCH] DROID-3710 fix --- .../anytype/domain/auth/interactor/LaunchAccount.kt | 9 ++++++++- .../anytype/domain/auth/interactor/ResumeAccount.kt | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/LaunchAccount.kt b/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/LaunchAccount.kt index 1c0266e0b0..7b85761278 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/LaunchAccount.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/LaunchAccount.kt @@ -7,11 +7,13 @@ import com.anytypeio.anytype.domain.auth.repo.AuthRepository import com.anytypeio.anytype.domain.base.BaseUseCase import com.anytypeio.anytype.domain.config.ConfigStorage import com.anytypeio.anytype.domain.config.UserSettingsRepository +import com.anytypeio.anytype.domain.debugging.Logger import com.anytypeio.anytype.domain.device.PathProvider import com.anytypeio.anytype.domain.platform.InitialParamsProvider import com.anytypeio.anytype.domain.workspace.SpaceManager import javax.inject.Inject import kotlin.coroutines.CoroutineContext +import kotlin.math.log import kotlinx.coroutines.Dispatchers /** @@ -25,6 +27,7 @@ class LaunchAccount @Inject constructor( private val initialParamsProvider: InitialParamsProvider, private val settings: UserSettingsRepository, private val awaitAccountStartManager: AwaitAccountStartManager, + private val logger: Logger, context: CoroutineContext = Dispatchers.IO ) : BaseUseCase(context) { @@ -45,7 +48,11 @@ class LaunchAccount @Inject constructor( configStorage.set(config = setup.config) val lastSessionSpace = settings.getCurrentSpace() if (lastSessionSpace != null) { - spaceManager.set(lastSessionSpace.id) + spaceManager.set(lastSessionSpace.id).onFailure { + logger.logException(it, "Error while restoring last session space") + // Clearing current space in case of error. + settings.clearCurrentSpace() + } } awaitAccountStartManager.setState(AwaitAccountStartManager.State.Started) setup.config.analytics diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/ResumeAccount.kt b/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/ResumeAccount.kt index 918af74cc0..c5847c0cc2 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/ResumeAccount.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/auth/interactor/ResumeAccount.kt @@ -50,8 +50,10 @@ class ResumeAccount @Inject constructor( if (lastSessionSpace != null) { val result = spaceManager.set(lastSessionSpace.id) if (result.isFailure) { - // Falling back to the default space + // Falling back to the default space. TODO - check behavior spaceManager.set(setup.config.space) + // TODO clear settings to avoid inconsistent states. + } } setup.account.id