Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions RocketCall/View/Mission/List/MissionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class MissionViewController: UIViewController {
private let pauseResumeMissionSubject = PublishSubject<UUID>()
private let stopMissionSubject = PublishSubject<UUID>()

private let deleteMissionSubject = PublishSubject<MissionPayload>()

private lazy var dataSource: UICollectionViewDiffableDataSource<MissionSection, MissionItem> = {
let dataSource = UICollectionViewDiffableDataSource<MissionSection, MissionItem>(collectionView: mainView.collectionView) {[weak self] collectionView, indexPath, itemIdentifier in
guard let self else { fatalError("Error: self is nil") }
Expand Down Expand Up @@ -171,6 +173,18 @@ extension MissionViewController {
})
.disposed(by: disposeBag)
*/

deleteMissionSubject
.subscribe(onNext: { [weak self] mission in
guard let self else { return }
do {
try self.coreDataManager.deleteMissionEntity(of: mission.id)
self.initialLoadSubject.onNext(())
} catch {
self.showErrorAlert(error: .saveFailed)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

deleteMissionEntity(of:) 메서드는 .saveFailed 외에도 다양한 CoreDataError를 발생시킬 수 있습니다. 예를 들어, fetchMissionEntity가 실패하면 .loadFailed.empty 오류가 발생할 수 있습니다. 현재 catch 블록은 모든 오류를 .saveFailed로 처리하여 사용자에게 부정확한 오류 정보를 보여줄 수 있습니다. 발생한 실제 오류를 전달하여 더 정확한 피드백을 제공해야 합니다.

                    if let coreDataError = error as? CoreDataManager.CoreDataError {
                        self.showErrorAlert(error: coreDataError)
                    } else {
                        self.showErrorAlert(error: .saveFailed)
                    }
References
  1. Swallowed or mishandled errors that obscure failure causes should be classified as high severity. The current implementation misrepresents the error type, which can make debugging difficult and provide a poor user experience. (link)
  2. When displaying errors to the user, provide specific and meaningful messages based on the error type instead of a generic message.

}
})
.disposed(by: disposeBag)
}
}

Expand All @@ -181,6 +195,19 @@ extension MissionViewController {
mainView.collectionView.register(CustomMissionCell.self, forCellWithReuseIdentifier: CustomMissionCell.id)
mainView.collectionView.register(MissionHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: MissionHeaderView.id)
}

func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
guard let item = dataSource.itemIdentifier(for: indexPath),
case .customMission(let mission) = item else { return nil }

return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let delete = UIAction(title: "삭제", image: UIImage(systemName: "trah.fill"), attributes: .destructive) { [weak self] _ in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

UIImage의 시스템 이름에 오타가 있습니다. "trah.fill"이 아니라 "trash.fill"이어야 합니다. 이 오타 때문에 삭제 아이콘이 표시되지 않습니다.

Suggested change
let delete = UIAction(title: "삭제", image: UIImage(systemName: "trah.fill"), attributes: .destructive) { [weak self] _ in
let delete = UIAction(title: "삭제", image: UIImage(systemName: "trash.fill"), attributes: .destructive) { [weak self] _ in
References
  1. Visible UI bugs should be classified as high severity. A typo causing a missing icon is a clear UI bug that degrades the user experience. (link)

self?.deleteMissionSubject.onNext(mission)
}
return UIMenu(title: "",children: [delete])
}
}

}

extension MissionViewController: UICollectionViewDelegate {
Expand Down
Loading