Skip to content

Commit

Permalink
#297: Share Extension 통신 에러 발생에 따른 에러 팝업 렌더링
Browse files Browse the repository at this point in the history
- 정상 동작을 위한 재기동을 위해 팝업 확인 버튼 클릭 시, Share Extension 종료
  • Loading branch information
joseph704 committed Aug 20, 2024
1 parent 7fde765 commit 9815fca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 18 additions & 1 deletion StreetDrop/ShareExtension/View/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import RxRelay
import RxGesture
import SnapKit

final class ShareViewController: UIViewController {
final class ShareViewController: UIViewController, Alertable {
enum Constant {
static let commentPlaceHolder: String = "노래, 현재 감정, 상황, 관련 에피소드, 거리, 가수 등 떠오르는 말을 적어보세요."
static let communityButtonTitle: String = "커뮤니티 가이드"
Expand Down Expand Up @@ -458,6 +458,23 @@ private extension ShareViewController {
failedLoadingMusicView.isHidden = false
view.layoutIfNeeded()
})

output.errorAlertShow
.bind(with: self) { owner, errorMessage in
owner.showAlert(
type: .alert(
onConfirm: { [weak self] in
self?.extensionContext?.completeRequest(
returningItems: nil,
completionHandler: nil
)
}
),
state: .primary,
title: "에러 발생",
subText: errorMessage,
buttonTitle: "확인"
)
}
.disposed(by: disposeBag)
}
Expand Down
13 changes: 8 additions & 5 deletions StreetDrop/ShareExtension/ViewModel/ShareViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ final class ShareViewModel: NSObject, ShareViewModelType {
var goFailedLoadingMusicView: Observable<Void> {
goFailedLoadingMusicViewRelay.asObservable()
}
fileprivate let errorAlertShowRelay: PublishRelay<String> = .init()
var errorAlertShow: Observable<String> {
errorAlertShowRelay.asObservable()
}
}

func convert(input: Input, disposedBag: DisposeBag) -> Output {
Expand Down Expand Up @@ -113,17 +117,17 @@ final class ShareViewModel: NSObject, ShareViewModelType {
input.dropButtonClickEvent
.bind(with: self) { owner, _ in
guard let selectedMusic = owner.selectedMusic else {
// TODO: 요셉, 선택한 음악정보 없다는 에러팝업
owner.output.errorAlertShowRelay.accept("선택한 음악 정보가 없습니다.")
return
}

guard let comment = owner.comment else {
// TODO: 코멘트 없다는 에러팝업
owner.output.errorAlertShowRelay.accept("코멘트가 없습니다.")
return
}

guard let currentLocation = owner.currentLocation else {
// TODO: 현재 위치정보 없다는 에러팝업
owner.output.errorAlertShowRelay.accept("현재 위치정보가 없습니다.")
return
}

Expand All @@ -139,8 +143,7 @@ final class ShareViewModel: NSObject, ShareViewModelType {
(selectedMusic, currentLocation.address, comment)
)
} onFailure: { owner, error in
// TODO: 드랍 실패 팝업
print(error.localizedDescription)
owner.output.errorAlertShowRelay.accept("드랍에 실패 했습니다.")
}
.disposed(by: disposedBag)

Expand Down

0 comments on commit 9815fca

Please sign in to comment.