-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 최근 로그인 계정 정보 안내 기능 구현 #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.ninecraft.booket.core.datastore.api.datasource | ||
|
|
||
| import com.ninecraft.booket.core.model.LoginMethod | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| interface LoginMethodDataSource { | ||
| val recentLoginMethod: Flow<LoginMethod> | ||
| suspend fun setRecentLoginMethod(loginMethod: LoginMethod) | ||
| suspend fun clearRecentLoginMethod() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.ninecraft.booket.core.datastore.impl.datasource | ||
|
|
||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import androidx.datastore.preferences.core.edit | ||
| import androidx.datastore.preferences.core.stringPreferencesKey | ||
| import com.ninecraft.booket.core.datastore.api.datasource.LoginMethodDataSource | ||
| import com.ninecraft.booket.core.datastore.impl.di.LoginMethodDataStore | ||
| import com.ninecraft.booket.core.datastore.impl.util.handleIOException | ||
| import com.ninecraft.booket.core.di.DataScope | ||
| import com.ninecraft.booket.core.model.LoginMethod | ||
| import dev.zacsweers.metro.Inject | ||
| import dev.zacsweers.metro.SingleIn | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.map | ||
|
|
||
| @SingleIn(DataScope::class) | ||
| @Inject | ||
| class DefaultLoginMethodDataSource( | ||
| @LoginMethodDataStore private val dataStore: DataStore<Preferences>, | ||
| ) : LoginMethodDataSource { | ||
| override val recentLoginMethod: Flow<LoginMethod> = dataStore.data | ||
| .handleIOException() | ||
| .map { prefs -> | ||
| val method = prefs[RECENT_LOGIN_METHOD] | ||
| when (method) { | ||
| "KAKAO" -> LoginMethod.KAKAO | ||
| "GOOGLE" -> LoginMethod.GOOGLE | ||
| else -> LoginMethod.NONE | ||
| } | ||
| } | ||
|
|
||
| override suspend fun setRecentLoginMethod(loginMethod: LoginMethod) { | ||
| dataStore.edit { prefs -> | ||
| prefs[RECENT_LOGIN_METHOD] = loginMethod.name | ||
| } | ||
| } | ||
|
|
||
| override suspend fun clearRecentLoginMethod() { | ||
| dataStore.edit { prefs -> | ||
| prefs.remove(RECENT_LOGIN_METHOD) | ||
| } | ||
| } | ||
|
|
||
| companion object { | ||
| private val RECENT_LOGIN_METHOD = stringPreferencesKey("RECENT_LOGIN_METHOD") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.ninecraft.booket.core.model | ||
|
|
||
| enum class LoginMethod { | ||
| NONE, | ||
| KAKAO, | ||
| GOOGLE, | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||||||||
| package com.ninecraft.booket.feature.login | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| import androidx.compose.runtime.Composable | ||||||||||||||||||||||||||||||
| import androidx.compose.runtime.LaunchedEffect | ||||||||||||||||||||||||||||||
| import androidx.compose.runtime.getValue | ||||||||||||||||||||||||||||||
| import androidx.compose.runtime.mutableStateOf | ||||||||||||||||||||||||||||||
| import androidx.compose.runtime.rememberCoroutineScope | ||||||||||||||||||||||||||||||
|
|
@@ -10,6 +11,7 @@ import com.ninecraft.booket.core.common.constants.ErrorScope | |||||||||||||||||||||||||||||
| import com.ninecraft.booket.core.common.event.postErrorDialog | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.core.data.api.repository.AuthRepository | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.core.data.api.repository.UserRepository | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.core.model.LoginMethod | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.feature.screens.HomeScreen | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.feature.screens.LoginScreen | ||||||||||||||||||||||||||||||
| import com.ninecraft.booket.feature.screens.TermsAgreementScreen | ||||||||||||||||||||||||||||||
|
|
@@ -50,6 +52,15 @@ class LoginPresenter( | |||||||||||||||||||||||||||||
| val scope = rememberCoroutineScope() | ||||||||||||||||||||||||||||||
| var isLoading by rememberRetained { mutableStateOf(false) } | ||||||||||||||||||||||||||||||
| var sideEffect by rememberRetained { mutableStateOf<LoginSideEffect?>(null) } | ||||||||||||||||||||||||||||||
| var showLoginTooltip by rememberRetained { mutableStateOf(false) } | ||||||||||||||||||||||||||||||
| var recentLoginMethod by rememberRetained { mutableStateOf(LoginMethod.NONE) } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| LaunchedEffect(Unit) { | ||||||||||||||||||||||||||||||
| authRepository.recentLoginMethod.collect { method -> | ||||||||||||||||||||||||||||||
| recentLoginMethod = method | ||||||||||||||||||||||||||||||
| showLoginTooltip = method != LoginMethod.NONE | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 툴팁 해제 후 다시 표시되는 잠재적 문제가 있습니다.
해제 상태를 별도로 추적하거나, 🔎 제안하는 수정 방안+ var hasUserDismissedTooltip by rememberRetained { mutableStateOf(false) }
+
LaunchedEffect(Unit) {
authRepository.recentLoginMethod.collect { method ->
recentLoginMethod = method
- showLoginTooltip = method != LoginMethod.NONE
+ showLoginTooltip = method != LoginMethod.NONE && !hasUserDismissedTooltip
}
}그리고 is LoginUiEvent.OnDismissLoginTooltip -> {
showLoginTooltip = false
+ hasUserDismissedTooltip = true
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| fun navigateAfterLogin() { | ||||||||||||||||||||||||||||||
| scope.launch { | ||||||||||||||||||||||||||||||
|
|
@@ -97,6 +108,7 @@ class LoginPresenter( | |||||||||||||||||||||||||||||
| isLoading = true | ||||||||||||||||||||||||||||||
| authRepository.login(event.accessToken) | ||||||||||||||||||||||||||||||
| .onSuccess { | ||||||||||||||||||||||||||||||
| authRepository.setRecentLoginMethod(LoginMethod.KAKAO) | ||||||||||||||||||||||||||||||
| userRepository.syncFcmToken() | ||||||||||||||||||||||||||||||
| navigateAfterLogin() | ||||||||||||||||||||||||||||||
| }.onFailure { exception -> | ||||||||||||||||||||||||||||||
|
|
@@ -120,6 +132,10 @@ class LoginPresenter( | |||||||||||||||||||||||||||||
| is LoginUiEvent.OnCloseButtonClick -> { | ||||||||||||||||||||||||||||||
| navigator.pop() | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| is LoginUiEvent.OnDismissLoginTooltip -> { | ||||||||||||||||||||||||||||||
| showLoginTooltip = false | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -131,6 +147,8 @@ class LoginPresenter( | |||||||||||||||||||||||||||||
| isLoading = isLoading, | ||||||||||||||||||||||||||||||
| returnToScreen = screen.returnToScreen, | ||||||||||||||||||||||||||||||
| sideEffect = sideEffect, | ||||||||||||||||||||||||||||||
| showLoginTooltip = showLoginTooltip, | ||||||||||||||||||||||||||||||
| recentLoginMethod = recentLoginMethod, | ||||||||||||||||||||||||||||||
| eventSink = ::handleEvent, | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: YAPP-Github/Reed-Android
Length of output: 1459
logout() 메서드에서 clearRecentLoginMethod() 호출 누락
logout()메서드에서clearRecentLoginMethod()를 호출하지 않고 있습니다.withdraw()메서드에서는 호출되고 있으나,logout()에서는 누락되어 있습니다. 사용자가 로그아웃 후 다시 로그인 화면에 접근할 때 이전 로그인 방식이 표시되는 불일치한 동작이 발생합니다.logout()메서드에도clearRecentLoginMethod()를 추가하여withdraw()와 일관성 있게 수정해주세요.🤖 Prompt for AI Agents