Skip to content
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

Merged
merged 9 commits into from
Nov 23, 2023

Conversation

Amepistheo
Copy link
Member

@Amepistheo Amepistheo commented Nov 21, 2023

관련 이슈

개요

리뷰 수정/삭제 서버 연결 코드 MVVM으로 변경
지도 관련 코드 삭제

작업 사항

  • 서버 연결 코드를 viewModel로 이동
  • Activity에서는 observe를 통해 toast message와 Done 여부를 viewModel에서 받아옴
  • Done인 경우 finish()를 통해 Activity 종료

Check List

  • code formatter 적용 확인 (ctrl + alert + O ⇒ 안쓰는 import 제거 / ctrl + alert + L ⇒ 코드 정렬 등)
  • PR 제목을 커밋 규칙에 맞게 작성
  • PR에 해당되는 Issue를 연결 완료
  • 작업한 사람 모두를 Assign
  • 작업한 팀에게 Code Review 요청 (Reviewer 등록)
  • main 브랜치의 최신 상태를 반영하고 있는지 확인

스크린샷 및 작동 영상

@Amepistheo Amepistheo linked an issue Nov 21, 2023 that may be closed by this pull request
3 tasks
@Amepistheo Amepistheo requested a review from HI-JIN2 November 21, 2023 12:22
@Amepistheo Amepistheo changed the title [REFACTORING] 리뷰 수정/삭제, 신고하기 MVVM 변경 #94 [REFACTORING] 리뷰 수정/삭제, 신고하기 MVVM 변경 Nov 21, 2023
Copy link
Member

@HI-JIN2 HI-JIN2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~!~! 한층 성장된 코드 👍

Comment on lines +25 to +44
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("삭제가 실패하였습니다.")
}
})
}
}
Copy link
Member

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()
            })
        }```

@HI-JIN2 HI-JIN2 merged commit 1ca8a02 into main Nov 23, 2023
1 check passed
@HI-JIN2 HI-JIN2 deleted the 94-refactoring-mvvm-+-design-system-2 branch November 23, 2023 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactoring: mvvm] 리뷰 수정/삭제/신고 리팩토링
2 participants