-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Splash를 보여주고 난 뒤, 유저 데이터에 따라 화면 이동
- Loading branch information
1 parent
5f5b40e
commit e21b8a0
Showing
7 changed files
with
57 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
feature/navigator/src/main/java/com/susu/feature/navigator/initialization/InitialRoute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.susu.feature.navigator.initialization | ||
|
||
enum class InitialRoute { | ||
SIGNUP_VOTE, LOGIN, RECEIVED | ||
SIGNUP_VOTE, LOGIN, RECEIVED, NONE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 28 additions & 1 deletion
29
feature/navigator/src/main/java/com/susu/feature/navigator/initialization/MainViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,35 @@ | ||
package com.susu.feature.navigator.initialization | ||
|
||
import androidx.lifecycle.viewModelScope | ||
import com.susu.core.ui.base.BaseViewModel | ||
import com.susu.domain.usecase.LoginUseCase | ||
import com.susu.feature.loginsignup.social.KakaoLoginHelper | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class MainViewModel @Inject constructor() : BaseViewModel<MainContract.MainState, MainContract.MainEffect>(MainContract.MainState.Loading) | ||
class MainViewModel @Inject constructor( | ||
private val loginUseCase: LoginUseCase, | ||
) : BaseViewModel<MainContract.MainState, MainContract.MainEffect>(MainContract.MainState()) { | ||
init { | ||
if (!KakaoLoginHelper.hasKakaoLoginHistory()) { | ||
intent { copy(isLoading = false, initialRoute = InitialRoute.SIGNUP_VOTE) } | ||
} else { | ||
KakaoLoginHelper.getAccessToken { oauthAccessToken -> | ||
if (oauthAccessToken == null) { | ||
intent { copy(isLoading = false, initialRoute = InitialRoute.LOGIN) } | ||
} else { | ||
viewModelScope.launch { | ||
loginUseCase(oauthAccessToken = oauthAccessToken) | ||
.onSuccess { | ||
intent { copy(isLoading = false, initialRoute = InitialRoute.RECEIVED) } | ||
}.onFailure { | ||
intent { copy(isLoading = false, initialRoute = InitialRoute.LOGIN) } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |