Skip to content

Commit 97e6980

Browse files
authored
[Feature/#268] 연락처 차단 완료 시 Toast 띄우기 (#269)
* feat: 연락처 차단 업데이트 시 Toast 띄우기 * feat: 연락처 차단 업데이트 클릭 시 Alert 추가
1 parent d3c2872 commit 97e6980

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

Projects/Feature/MyPage/Interface/Sources/MyPage/MyPageFeature.swift

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,21 @@ extension MyPageFeature {
9595
await send(.withdrawalDidCompleted)
9696
}
9797

98+
case .dismissAlert:
99+
state.destination = nil
100+
return .send(.configureLoadingProgressView(isShow: false))
101+
98102
case .dismissContactsAlert:
99103
state.destination = nil
100104
URLHandler.shared.openURL(urlType: .setting)
101105
return .none
106+
107+
case let .confirmBlockContacts(contacts):
108+
return .run { send in
109+
try await userClient.updateBlockContacts(contacts: contacts)
110+
await send(.updatePhoneNumberForBlockCompleted(count: contacts.count))
111+
await send(.configureLoadingProgressView(isShow: false))
112+
}
102113
}
103114

104115
case .userProfileDidFetched(let userProfile):
@@ -147,9 +158,7 @@ extension MyPageFeature {
147158
return .run { send in
148159
await send(.configureLoadingProgressView(isShow: true))
149160
let contacts = try await userClient.fetchContacts()
150-
try await userClient.updateBlockContacts(contacts: contacts)
151-
await send(.updatePhoneNumberForBlockCompleted(count: contacts.count))
152-
await send(.configureLoadingProgressView(isShow: false))
161+
await send(.contactsDidReceived(contacts: contacts))
153162
} catch: { error, send in
154163
await send(.configureLoadingProgressView(isShow: false))
155164
if let userError = error as? UserError {
@@ -161,12 +170,24 @@ extension MyPageFeature {
161170
}
162171
}
163172
}
173+
174+
case let .contactsDidReceived(contacts):
175+
let count = contacts.count
176+
state.destination = .alert(.init(
177+
title: { TextState("연락처 차단") },
178+
actions: {
179+
ButtonState(role: .cancel, action: .dismissAlert, label: { TextState("취소하기")})
180+
ButtonState(role: .destructive, action: .confirmBlockContacts(contacts: contacts), label: { TextState("차단하기")})
181+
},
182+
message: { TextState("주소록에 있는 \(count)개의\n전화번호를 차단할까요?") }))
183+
return .none
164184

165185
case .updateApplicationButtonTapped:
166186
URLHandler.shared.openURL(urlType: .bottleAppStore)
167187
return .none
168188

169189
case let .updatePhoneNumberForBlockCompleted(count):
190+
toastClient.presentToast(message: "차단이 완료됐어요")
170191
state.blockedContactsCount = count
171192
return .none
172193

Projects/Feature/MyPage/Interface/Sources/MyPage/MyPageFeatureInterface.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public struct MyPageFeature {
7676
case privacyPolicyListDidTapped
7777
case termsWebViewDidDismiss
7878
case contactListDidTapped
79-
79+
case contactsDidReceived(contacts: [String])
8080
case configureLoadingProgressView(isShow: Bool)
8181

8282
case delegate(Delegate)
@@ -95,6 +95,8 @@ public struct MyPageFeature {
9595
public enum Alert: Equatable {
9696
case confirmLogOut
9797
case confirmWithdrawal
98+
case confirmBlockContacts(contacts: [String])
99+
case dismissAlert
98100
case dismissContactsAlert
99101
}
100102

0 commit comments

Comments
 (0)