Skip to content

Commit

Permalink
[FEAT/#226] 프로필 수정 활성화 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Sep 8, 2024
1 parent 2a6e3df commit 67de6b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ data class ProfileEditState(
val profile: String = "",
val initialProfile: String = "",
val initialView: Boolean = true,
val isModified: Boolean = false,
val isButtonValid: Boolean = false,
val authType: String = "",
val showBottomSheet: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ class ProfileEditViewModel @Inject constructor(
fun updateName(name: String) {
_state.value = _state.value.copy(
name = name,
initialView = false
initialView = false,
isModified = true
)
}

fun updateProfile(profile: String) {
val isSameAsInitial = profile == _state.value.initialProfile
val isSameAsPrevious = profile == _state.value.profile

_state.value = _state.value.copy(
profile = profile,
initialView = profile == _state.value.initialProfile
initialView = !_state.value.isModified && isSameAsInitial,
isModified = if (isSameAsPrevious) _state.value.isModified else !isSameAsInitial
)
}

Expand Down

0 comments on commit 67de6b4

Please sign in to comment.