Skip to content

Commit faccab8

Browse files
committed
Improve notice presentation
1 parent a8bfd78 commit faccab8

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

Modules/Sources/Yosemite/Actions/BookingAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public enum BookingAction: Action {
9292
bookingID: Int64,
9393
onCompletion: (Error?) -> Void)
9494

95-
/// Updates a booking attendance status.
95+
/// Updates a booking note.
9696
///
9797
/// - Parameter siteID: The site ID of the booking.
9898
/// - Parameter bookingID: The ID of the booking to be updated.

WooCommerce/Classes/ViewModels/Booking Details/BookingDetailsViewModel.swift

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@ extension BookingDetailsViewModel {
242242
) { [weak self] error in
243243
if let error, let self {
244244
DDLogError("⛔️ Error updating booking attendance status: \(error)")
245-
displayAttendanceStatusUpdatedErrorNotice(status: newStatus)
245+
displayErrorNotice(
246+
messageFormat: Localization.bookingAttendanceStatusUpdateFailedMessage
247+
) { [weak self] in
248+
self?.updateAttendanceStatus(to: newStatus)
249+
}
246250
}
247251
}
248252
stores.dispatch(action)
@@ -256,27 +260,32 @@ extension BookingDetailsViewModel {
256260
) { [weak self] error in
257261
if let error, let self {
258262
DDLogError("⛔️ Error updating booking note: \(error)")
259-
// displayAttendanceStatusUpdatedErrorNotice(status: newStatus)
263+
displayErrorNotice(
264+
messageFormat: Localization.bookingNoteUpdateFailedMessage
265+
) { [weak self] in
266+
self?.updateNote(to: newNote)
267+
}
260268
}
261269
}
262270
stores.dispatch(action)
263271
}
264272

265-
private func displayAttendanceStatusUpdatedErrorNotice(status: BookingAttendanceStatus) {
273+
private func displayErrorNotice(
274+
messageFormat: String,
275+
retry: @escaping () -> Void
276+
) {
266277
let text = String.localizedStringWithFormat(
267-
Localization.bookingAttendanceStatusUpdateFailedMessage,
278+
messageFormat,
268279
booking.bookingID
269280
)
270-
self.notice = Notice(
281+
282+
notice = Notice(
271283
message: text,
272284
feedbackType: .error,
273285
actionTitle: Localization.retryActionTitle
274286
) { [weak self] in
275-
guard let self else {
276-
return
277-
}
278-
279-
updateAttendanceStatus(to: status)
287+
guard let self else { return }
288+
retry()
280289
}
281290
}
282291
}
@@ -489,6 +498,14 @@ private extension BookingDetailsViewModel {
489498
+ "Parameters: %1$d - Booking number"
490499
)
491500

501+
static let bookingNoteUpdateFailedMessage = NSLocalizedString(
502+
"BookingDetailsView.bookingNote.failureMessage.",
503+
value: "Unable to update note of Booking #%1$d.",
504+
comment: "Content of error presented when updating the not of a Booking fails. "
505+
+ "It reads: Unable to update note of Booking #{Booking number}. "
506+
+ "Parameters: %1$d - Booking number"
507+
)
508+
492509
static let bookingCancellationFailedMessage = NSLocalizedString(
493510
"BookingDetailsView.cancellation.failureMessage",
494511
value: "Unable to cancel Booking #%1$d.",

0 commit comments

Comments
 (0)