-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: 프로필 수정 API 연결 #230
feat: 프로필 수정 API 연결 #230
Conversation
@Serializable | ||
data class UserNicknameValidityResponseDto( | ||
@SerialName("isValid") | ||
val isValid: Boolean |
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.
r: 트레일링콤마
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.
화긴
return userApi.getNicknameValidity(nickname).isValid | ||
} | ||
|
||
suspend fun patchUserProfile(avatarId: Int?, nickname: String?, intro: String?, genrePreferences: List<String>) { |
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.
c: 패치요?
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.
엥 save인데 뭐지
val intent = ProfileEditActivity.getIntent( | ||
requireContext(), | ||
nickname = "밝보", | ||
introduction = "만나서 반가워요!", | ||
avatarImageUrl = "https://mblogthumb-phinf.pstatic.net/MjAyMjA3MDdfMTgg/MDAxNjU3MTIwODE3MDU5.4sNUX1NFnBHQsQ8xrq6Fd2mrVrtyipj6H9aLuJIpyj0g.h-orck6dDWA-ErMcplHgzh-2bPPk7TEAJwxrnNr5qoQg.PNG.ssankal78/청명.png?type=w800", | ||
genrePreferences = arrayListOf("fantasy", "romance"), |
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.
c: 객체로 묶는게 이쁠 것 같아요. uimodel을 넘기시죠
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.
여기 관련 확장함수를 그냥 추가하는게 예쁠 것 같습니다 👍
) | ||
binding.tvProfileEditNickname.isSelected = uiState.profile.nicknameModel.nickname.isNotEmpty() | ||
binding.tvProfileEditNicknameError.text = uiState.nicknameEditResult.message | ||
val defaultState = uiState.nicknameEditResult != NicknameEditResult.VALID_NICKNAME && uiState.nicknameEditResult != NicknameEditResult.NONE |
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.
c: sealed 혹은 enum들은 가급적이면 다 임포트해주세요
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.
오 훨씬 깔끔해지네요 소소팁 감사 👍
; | ||
|
||
companion object { | ||
fun String.checkNicknameValidity(): NicknameEditResult { |
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.
c: 이넘클래스의 역할에 대해 다시 생각해봐도 좋겠어요
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.
값을 나열해주는 클래스에서 로직이 들어간다면 어색할 수 있겠네요 🤔 이런 비즈니스 로직같은 친구는 다른 곳에 있어야 할 것 같습니다
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.
수고하셨습니다! 질문 남겨놓은 게 많아서 코멘트 확인 후에 어프루브 드리겠슴다 ( _ _ 👍
return UserProfileRequestDto( | ||
avatarId = avatarId, | ||
nickname = nickname, | ||
intro = intro, | ||
genrePreferences = genrePreferences, | ||
) | ||
} |
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.
a: 요 부분은 저도 리뷰 받은 거긴 한데 request를 사용할 때 매퍼를 만들어야 하나? 라는 리뷰를 받았어서 엔티티 클래스 생성하지 않고 바로 requestDto로 넘겨줘도 될 듯 함다
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.
사실 저도 현재 크게 분리할 필요성을 느끼지 못한 부분이긴 함당
companion object { | ||
private const val NICKNAME = "NICKNAME" | ||
private const val INTRODUCTION = "INTRODUCTION" | ||
private const val AVATAR_IMAGE_URL = "AVATAR_IMAGE_URL" | ||
private const val GENRE_PREFERENCES = "GENRE_PREFERENCES" | ||
|
||
fun getIntent(context: Context, nickname: String, introduction: String, avatarImageUrl: String, genrePreferences: List<String>): Intent { | ||
return Intent(context, ProfileEditActivity::class.java).apply { | ||
putExtra(NICKNAME, nickname) | ||
putExtra(INTRODUCTION, introduction) | ||
putExtra(AVATAR_IMAGE_URL, avatarImageUrl) | ||
putStringArrayListExtra(GENRE_PREFERENCES, genrePreferences as ArrayList<String>) | ||
} | ||
} | ||
} |
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.
a: activity 내에서 데이터 통신 데이터를 사용하지 않고, intent 객체에 데이터 값을 받아오는 이유가 무엇인가욥? 코드 봤을 때, 조회 api를 사용하면 뷰가 훨씬 가벼워질 것 같다는 생각이 드는데!
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.
이미 이전 뷰에서 무조건 가지고 있어야 할 정보를 위해 네트워크를 한번 더 찌르는게 성능이나 리소스 사용 면에서 좋지 못하다고 생각했습니다. 만약 가독성을 위해서라면 Serializable로 이번 수정에서 직렬화를 진행할 계획입니다 :)
private fun updateDuplicateCheckButton(uiState: ProfileEditUiState) { | ||
val isEnable = uiState.profile.nicknameModel.nickname.isNotEmpty() && uiState.nicknameEditResult == NicknameEditResult.NONE | ||
binding.tvProfileEditNicknameCheckDuplicate.setTextColor( | ||
if (isEnable) AppCompatResources.getColorStateList(this, R.color.primary_100_6A5DFD).defaultColor | ||
else AppCompatResources.getColorStateList(this, R.color.gray_200_AEADB3).defaultColor | ||
) | ||
binding.tvProfileEditNicknameCheckDuplicate.setBackgroundResource( | ||
if (isEnable) R.drawable.bg_profile_edit_primary_50_radius_12dp | ||
else R.drawable.bg_profile_edit_gray_70_radius_12dp | ||
) | ||
binding.tvProfileEditNicknameCheckDuplicate.isEnabled = isEnable | ||
} |
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.
c: 버튼이 활성화되기 위한 로직을 뷰에서 사용해야 하나요? 뷰모델에서 isEnabled
의 상태를 가지는 건 어떨지?
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.
확실히 뷰모델에서 가지는게 맞겠군요
binding.tvProfileEditNicknameCount.text = getColoredText( | ||
getString(R.string.profile_edit_nickname_max_count, uiState.profile.nicknameModel.nickname.length), | ||
listOf(uiState.profile.nicknameModel.nickname.length.toString()), | ||
AppCompatResources.getColorStateList(this, R.color.gray_300_52515F).defaultColor | ||
) | ||
binding.tvProfileEditNickname.isSelected = uiState.profile.nicknameModel.nickname.isNotEmpty() | ||
binding.tvProfileEditNicknameError.text = uiState.nicknameEditResult.message |
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.
c: 여기 binding 으로 한 번 묶으면 가독성이 훨씬 좋아질 것 같아요
}.also { websosoChip -> binding.wcgProfileEditPreferGenre.addChip(websosoChip) } | ||
} | ||
} | ||
|
||
private fun setupNicknameEditText() { |
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.
r: 리스너에 대한 코드니 메서드명이 달라야 할 것 같아요
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.
on-what-action 이 맞을까여
} | ||
} | ||
|
||
private fun setupIntroductionEditText() { |
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.
r: 여기도 마찬가지
avatarId = if (previousProfile.avatarImageUrl == currentProfile.avatarImageUrl) null else 1, | ||
nickname = if (previousProfile.nicknameModel.nickname == currentProfile.nicknameModel.nickname) null else currentProfile.nicknameModel.nickname, | ||
intro = if (previousProfile.introduction == currentProfile.introduction) null else currentProfile.introduction, | ||
genrePreferences = currentProfile.genrePreferences.map { it.tag }, |
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.
c: 이 로직 말고 다른 방법은 없는 건가욥??
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.
비교하는 함수를 하나 분리하는 것 이외에 크게 달라질 것은 없을 것 같습니다...! 기존과 같은 경우 서버에서 null값을 요구해서요
fun String.checkNicknameValidity(): NicknameEditResult { | ||
return when { | ||
this.length !in 2..10 -> INVALID_NICKNAME_LENGTH | ||
this.contains(Regex("^\\s|\\s$|[^\\w가-힣-_]|[ㄱ-ㅎㅏ-ㅣ]")) -> INVALID_NICKNAME_SPECIAL_CHARACTER |
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.
c: 검증 로직을 탈 때마다 정규식을 새롭게 생성하는 걸로 보이는데 성능 향상 고려하면 좋을 듯해유
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.
좋은 지적인듯요 Regex가 단순 문자열같은 느낌인줄
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="36dp" | ||
android:text="프로필 선택" |
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.
c: 스트링 추출
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.
이거 일부러 냅뒀음요 새로 이슈파서 뜯어야할거같아서
…o feat/227 # Conflicts: # app/src/main/java/com/teamwss/websoso/data/mapper/UserMapper.kt # app/src/main/java/com/teamwss/websoso/data/repository/UserRepository.kt # app/src/main/java/com/teamwss/websoso/ui/profileEdit/ProfileEditActivity.kt
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.
굿이에영
…to feat/250 # Conflicts: # app/src/main/java/com/teamwss/websoso/ui/profileEdit/ProfileEditViewModel.kt # app/src/main/java/com/teamwss/websoso/ui/profileEdit/model/ProfileEditUiModel.kt # app/src/main/res/layout/activity_profile_edit.xml
feat: 캐릭터 선택 구현
…o feat/227 # Conflicts: # app/src/main/java/com/teamwss/websoso/data/mapper/UserMapper.kt # app/src/main/java/com/teamwss/websoso/data/remote/api/UserApi.kt # app/src/main/java/com/teamwss/websoso/data/repository/UserRepository.kt # app/src/main/java/com/teamwss/websoso/ui/main/myPage/MyPageFragment.kt # app/src/main/res/values/strings.xml
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵
Screen_recording_20240827_162001.mp4
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴
TODO: 프로필 이미지 수정 추가, 에러 핸들링 추가
아직 마이페이지쪽에서 완성된게 없어서 실시간 테스트는 어려울 것 같네요...! 이미지 관련도 답변좀 들어봐야할듯
너무 양이 많아져서 중간에 끊었다가 갑니다