From 5436a15f96ad210f0f49f22a7484ec0472cadd13 Mon Sep 17 00:00:00 2001 From: EunsuSeo01 Date: Tue, 31 Dec 2024 21:03:30 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#319=20-=20VC=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=86=A0=EC=8A=A4=ED=8A=B8=20=EB=9D=84=EC=9A=B0=EB=8A=94=20?= =?UTF-8?q?=EA=B1=B8=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/HankkiDetailViewController.swift | 8 ++++++-- .../ViewModel/HankkiDetailViewModel.swift | 13 ++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift index 9be9f4ac..f1482072 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/View/HankkiDetailViewController.swift @@ -185,8 +185,12 @@ private extension HankkiDetailViewController { primaryButtonText: StringLiterals.Alert.check) } - viewModel.dismiss = { - self.navigationController?.popViewController(animated: false) + viewModel.dismiss = { [weak self] in + self?.navigationController?.popViewController(animated: false) + } + + viewModel.handleDeletedHankki = { [weak self] in + self?.showBlackToast(message: StringLiterals.Toast.deleteAlready) } } diff --git a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift index a3d1b8c7..3b5ea358 100644 --- a/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift +++ b/Hankkijogbo/Hankkijogbo/Present/HankkiDetail/ViewModel/HankkiDetailViewModel.swift @@ -8,7 +8,6 @@ import Foundation import Moya -import UIKit final class HankkiDetailViewModel { @@ -34,6 +33,8 @@ final class HankkiDetailViewModel { var setHankkiDetailData: (() -> Void)? var showAlert: ((String) -> Void)? var dismiss: (() -> Void)? + var handleMapError: (() -> Void)? + var handleDeletedHankki: (() -> Void)? init(hankkiId: Int) { self.hankkiId = hankkiId @@ -47,8 +48,8 @@ extension HankkiDetailViewModel { guard let self = self else { return } switch result { case .notFound: - UIApplication.showBlackToast(message: StringLiterals.Toast.deleteAlready) - self.dismiss?() + handleDeletedHankki?() + dismiss?() default: result.handleNetworkResult(delegate: self.delegate) { response in self.hankkiDetailData = response.data @@ -88,10 +89,8 @@ private extension HankkiDetailViewModel { guard let detailData = hankkiDetailData else { return } NetworkService.shared.naverMapService.getHankkiAddress(latitude: detailData.latitude, longitude: detailData.longitude) { result in switch result { - case .badRequest: - UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) - case .serverError: - UIApplication.showBlackToast(message: StringLiterals.Toast.serverError) + case .badRequest, .serverError: + self.handleMapError?() default: result.handleNetworkResult { response in guard let data = response.results.first,