Skip to content

Commit

Permalink
Merge pull request #127 from DeveloperAcademy-POSTECH/fix/reviewRegis…
Browse files Browse the repository at this point in the history
…ter/null-image

[Fix] 리뷰 등록 이미지 처리 및 맛집리스트 새로고침 버그 수정
  • Loading branch information
Lia316 authored Dec 4, 2022
2 parents 73fa55f + f4bcfc7 commit 76c8787
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ extension ReviewRegisterUseCase {
menuName: String? = nil,
image: String? = nil,
grade: Evaluation) -> AnyPublisher<ReviewDetailDTO, NetworkError> {
// TODO: userDefaults 에 유저 아이디 꼭!! 저장해야함
// UserInfoManager.userInfo?.userID = 11
let user = UserInfoManager.userInfo?.userID ?? 11

guard let user = UserInfoManager.userInfo?.userID else {
return Fail(error: NetworkError.unauthorized("유저 아이디를 알 수 없습니다")).eraseToAnyPublisher()
}
let reviewDTO = RegisterReviewDTO(placeId: placeId,
menuName: menuName,
image: image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ extension PlaceListViewModel: ErrorMapper {
}

func initialFetch() {
placeType = .hot
prefetch(at: [1], willUpdate: false)
placeType = .whole
prefetch(at: [1])
if placeType == .whole {
placeType = .hot
prefetch(at: [1], willUpdate: false)
placeType = .whole
prefetch(at: [1])
} else if placeType == .hot {
placeType = .whole
prefetch(at: [1], willUpdate: false)
placeType = .hot
prefetch(at: [1])
}
}

func prefetch(at rows: [Int], willUpdate: Bool = true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ extension ReviewRegisterViewController: UIImagePickerControllerDelegate, UINavig
}
.store(in: &cancelBag)

viewModel.isRegisterFail
.receive(on: DispatchQueue.main)
.sink { [weak self] errorMessage in
print(errorMessage)
let alert = UIAlertController(title: "리뷰 등록 실패",
message: errorMessage,
preferredStyle: .alert)
let okAction = UIAlertAction(title: "확인", style: .default)
alert.addAction(okAction)
self?.present(alert, animated: false)
}
.store(in: &cancelBag)

viewModel.$isRegisterPossible
.receive(on: DispatchQueue.main)
.sink { [weak self] isUploaded in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension ReviewCardView {
.receive(on: DispatchQueue.main)
.sink { [weak self] image in
guard let self = self else { return }
let imageExist = !image.isEmpty
let imageExist = image != nil
self.reconfigureUI(for: imageExist)
self.remakeLayout(with: imageExist)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ReviewRegisterViewModel {
let placeName: String
var evaluation: Evaluation = .soso
var menu: String?
@Published var imageString = ""
@Published var imageString: String?
@Published var isRegisterPossible = true

// Output
Expand Down Expand Up @@ -101,6 +101,7 @@ extension ReviewRegisterViewModel: ErrorMapper {
guard let self = self else { return }

// TODO: ReviewDTO image 배열 -> String으로 바뀌면 수정 예정
// 나중에 유저가 여러 이미지를 한번에 등록할 수 있게 되나요? 이러면 투두 삭제 예정
var imageURL: URL?
if !review.image.isEmpty {
imageURL = URL(string: review.image[0] ?? "")
Expand Down

0 comments on commit 76c8787

Please sign in to comment.