Commit 9e9439d4 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Fix session scope initialization after process death.

parent cbdacf2a
......@@ -25,12 +25,15 @@ class LaunchInteractor @Inject constructor(
}
}
fun signInToSession(): Boolean {
val account = sessionRepository.getCurrentUserAccount()
Toothpick.closeScope(DI.SERVER_SCOPE)
Toothpick
.openScopes(DI.APP_SCOPE, DI.SERVER_SCOPE)
.installModules(ServerModule(account))
return account != null
val hasAccount: Boolean
get() = sessionRepository.getCurrentUserAccount() != null
fun signInToLastSession() {
if (!Toothpick.isScopeOpen(DI.SERVER_SCOPE)) {
val account = sessionRepository.getCurrentUserAccount()
Toothpick
.openScopes(DI.APP_SCOPE, DI.SERVER_SCOPE)
.installModules(ServerModule(account))
}
}
}
\ No newline at end of file
......@@ -13,11 +13,13 @@ class AppLauncher @Inject constructor(
private val router: Router
) {
fun coldStart() {
val isSignedIn = launchInteractor.signInToSession()
fun onLaunch() {
launchInteractor.signInToLastSession()
}
fun coldStart() {
val rootScreen =
if (isSignedIn) Screens.DrawerFlow
if (launchInteractor.hasAccount) Screens.DrawerFlow
else Screens.AuthFlow
if (launchInteractor.isFirstLaunch) {
......@@ -25,6 +27,5 @@ class AppLauncher @Inject constructor(
} else {
router.newRootScreen(rootScreen)
}
}
}
\ No newline at end of file
......@@ -56,6 +56,7 @@ class AppActivity : MvpAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
Toothpick.inject(this, Toothpick.openScope(DI.APP_SCOPE))
appLauncher.onLaunch()
super.onCreate(savedInstanceState)
setContentView(R.layout.layout_container)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment