fix an issue if a global deletion fails, the UI should toast and stay on the deletion modal.

pull/894/head
Ryan ZHAO 3 months ago
parent 8ca0b19391
commit d076892424

@ -2036,6 +2036,7 @@ extension ConversationVC:
confirmStyle: .danger, confirmStyle: .danger,
cancelTitle: "cancel".localized(), cancelTitle: "cancel".localized(),
cancelStyle: .alert_text, cancelStyle: .alert_text,
dismissOnConfirm: false,
onConfirm: { [weak self, dependencies = viewModel.dependencies] modal in onConfirm: { [weak self, dependencies = viewModel.dependencies] modal in
/// Determine the selected action index /// Determine the selected action index
let selectedIndex: Int = { let selectedIndex: Int = {
@ -2061,26 +2062,31 @@ extension ConversationVC:
.publisherForAction(at: selectedIndex, using: dependencies) .publisherForAction(at: selectedIndex, using: dependencies)
.sinkUntilComplete( .sinkUntilComplete(
receiveCompletion: { result in receiveCompletion: { result in
DispatchQueue.main.async {
self?.viewModel.showToast(
text: {
switch result { switch result {
case .finished: case .finished:
return "deleteMessageDeleted" DispatchQueue.main.async {
self?.viewModel.showToast(
text: "deleteMessageDeleted"
.putNumber(messagesToDelete.count) .putNumber(messagesToDelete.count)
.localized() .localized(),
backgroundColor: .backgroundSecondary,
inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
)
modal.dismiss(animated: true)
}
case .failure: case .failure:
return "deleteMessageFailed" DispatchQueue.main.async {
self?.viewModel.showToast(
text: "deleteMessageFailed"
.putNumber(messagesToDelete.count) .putNumber(messagesToDelete.count)
.localized() .localized(),
}
}(),
backgroundColor: .backgroundSecondary, backgroundColor: .backgroundSecondary,
inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing inset: (self?.inputAccessoryView?.frame.height ?? Values.mediumSpacing) + Values.smallSpacing
) )
} }
} }
}
) )
}, },
afterClosed: { [weak self] in afterClosed: { [weak self] in

Loading…
Cancel
Save