-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] 내 제휴, 닉네임 최초 값이 UI에 보이는 문제 해결 #395
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
Changes from 4 commits
4eabbfd
dee6d2d
3c88fba
152135f
5b49efd
1a50d67
0b08243
6c7a829
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,18 @@ | ||||||||||||||
| package com.eatssu.android.presentation.mypage | ||||||||||||||
|
|
||||||||||||||
| import android.content.Context | ||||||||||||||
| import androidx.lifecycle.ViewModel | ||||||||||||||
| import androidx.lifecycle.viewModelScope | ||||||||||||||
| import com.eatssu.android.BuildConfig | ||||||||||||||
| import com.eatssu.android.data.MySharedPreferences | ||||||||||||||
| import com.eatssu.android.data.repository.PreferencesRepository | ||||||||||||||
| import com.eatssu.android.domain.usecase.alarm.AlarmUseCase | ||||||||||||||
| import com.eatssu.android.domain.usecase.alarm.SetDailyNotificationStatusUseCase | ||||||||||||||
| import com.eatssu.android.domain.usecase.user.GetUserNickNameUseCase | ||||||||||||||
| import com.eatssu.android.presentation.UiEvent | ||||||||||||||
| import com.eatssu.android.presentation.UiState | ||||||||||||||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||||||||||||||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||||||||||||||
| import kotlinx.coroutines.Dispatchers | ||||||||||||||
| import kotlinx.coroutines.flow.MutableSharedFlow | ||||||||||||||
| import kotlinx.coroutines.flow.MutableStateFlow | ||||||||||||||
|
|
@@ -30,13 +33,20 @@ class MyPageViewModel @Inject constructor( | |||||||||||||
| private val getUserNickNameUseCase: GetUserNickNameUseCase, | ||||||||||||||
| private val setNotificationStatusUseCase: SetDailyNotificationStatusUseCase, | ||||||||||||||
| private val alarmUseCase: AlarmUseCase, | ||||||||||||||
| private val preferencesRepository: PreferencesRepository | ||||||||||||||
| private val preferencesRepository: PreferencesRepository, | ||||||||||||||
| @ApplicationContext private val context: Context | ||||||||||||||
| ) : ViewModel() { | ||||||||||||||
|
|
||||||||||||||
| // 내부는 항상 "값 그 자체"만 들고 있고, | ||||||||||||||
| // 화면엔 UiState로 감싸서 노출 | ||||||||||||||
| // 로컬 저장소에서 닉네임을 먼저 읽어서 초기 상태 설정 | ||||||||||||||
| private val _state = MutableStateFlow( | ||||||||||||||
| MyPageState(appVersion = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})") | ||||||||||||||
| MyPageState( | ||||||||||||||
| appVersion = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})", | ||||||||||||||
| nickname = MySharedPreferences.getUserName(context).takeIf { | ||||||||||||||
| it.isNotBlank() | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+44
to
+46
Contributor
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. ViewModel이 초기화될 때 다만, 현재 로직은 일관성을 유지하고, 'user-xxxx'와 같은 닉네임이 잠시 보였다가 사라지는 UI 깜빡임 현상을 방지하기 위해, 초기화 시점에도
Suggested change
|
||||||||||||||
| ) | ||||||||||||||
| ) | ||||||||||||||
| val uiState: StateFlow<UiState<MyPageState>> = | ||||||||||||||
| _state | ||||||||||||||
|
|
||||||||||||||
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.
getUserCollegeDepartmentUseCase 이 usecase가 존재해서 MySharedPreferences값을 직접 가져오는 것보다 usecase를 활용하면 어떨까요!!
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.
헉 잊고 있었네요 수정하겠습니다!