Skip to content

Commit

Permalink
fix logout
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Jan 30, 2024
1 parent c2e6c44 commit dc4ebbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.stslex.feature.profile.navigation

import com.stslex.core.ui.navigation.AppNavigator
import com.stslex.core.ui.navigation.AppScreen
import com.stslex.feature.profile.ui.store.ProfileStoreComponent

class ProfileRouterImpl(
Expand All @@ -10,6 +11,8 @@ class ProfileRouterImpl(
override fun invoke(
event: ProfileStoreComponent.Navigation
) {
TODO("Not yet implemented")
when (event) {
ProfileStoreComponent.Navigation.LogIn -> navigator.navigate(AppScreen.Auth)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,28 @@ class ProfileStore(

private fun actionLogout() {
val currentScreen = state.value.screen
if (currentScreen !is ProfileScreenState.Content) return

if (
currentScreen is ProfileScreenState.Content.Loading ||
currentScreen is ProfileScreenState.Shimmer
) {
return
}

updateState {
it.copy(screen = ProfileScreenState.Shimmer)
}
launch(
action = {
interactor.logOut()
},
onSuccess = {
updateState { state ->
state.copy(
screen = ProfileScreenState.Content.NotLoading(currentScreen.data)
)
}
navigate(Navigation.LogIn)
},
onError = { error ->
sendEvent(Event.ErrorSnackBar(error.message ?: "error logout"))
}
) {
interactor.logOut()
}
)
}

private fun actionLoadProfile(action: Action.LoadProfile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ interface ProfileStoreComponent : Store {
data class ErrorSnackBar(val message: String) : Event
}

sealed interface Navigation : Store.Navigation
sealed interface Navigation : Store.Navigation {

data object LogIn : Navigation
}
}

0 comments on commit dc4ebbf

Please sign in to comment.