Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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<Id, BaseUseCase.None>(context) {

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading