-
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
[REFACTORING] 리뷰 수정/삭제, 신고하기 MVVM 변경 #111
Conversation
… 94-refactoring-mvvm-+-design-system-2 # Conflicts: # app/src/main/java/com/eatssu/android/ui/review/etc/ReportActivity.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.
수고하셨습니다~!~! 한층 성장된 코드 👍
val service = RetrofitImpl.retrofit.create(ReviewService::class.java) | ||
|
||
viewModelScope.launch(Dispatchers.IO) { | ||
service.delReview(reviewId).enqueue(object : Callback<Void> { | ||
override fun onResponse(call: Call<Void>, response: Response<Void>) { | ||
if (response.isSuccessful) { | ||
if (response.code() == 200) { | ||
handleSuccessResponse("삭제가 완료되었습니다.") | ||
} else { | ||
handleErrorResponse("삭제가 실패하였습니다.") | ||
} | ||
} | ||
} | ||
|
||
override fun onFailure(call: Call<Void>, t: Throwable) { | ||
handleErrorResponse("삭제가 실패하였습니다.") | ||
} | ||
}) | ||
} | ||
} |
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.
저도 이렇게 수정해서 pr 반영했습니다! 제가 썼던 코드가 레포지토리 패턴이 아닌데 이름만 레포지토리인 원효대사 해골물 같은 코드였어서 그냥 뷰모델에서 서비스 호출하는걸로 바꿨어요!
다만 enqueue 방식이 아니라, runCatching를 쓰면 좀 더 가독성이 좋아질 것 같은데, 이건 다른 issue에서 처리하도록 합죠!
kotlin.runCatching {
setUserInfoService.setAge(
request = RequestSetAgeDto(
age = selectedAge.value ?: throw NullPointerException()
)
)
}.fold(onSuccess = {
_setAgeSuccessResponse.value = true
}, onFailure = { error ->
_setAgeErrorResponse.value = error.getErrorMessage()
})
}```
관련 이슈
개요
작업 사항
Check List
ctrl + alert + O
⇒ 안쓰는 import 제거 /ctrl + alert + L
⇒ 코드 정렬 등)main
브랜치의 최신 상태를 반영하고 있는지 확인스크린샷 및 작동 영상