Skip to content

Commit 78c2774

Browse files
committed
Make sure the swipe actions are only avilable for non-completed orders
1 parent 665f753 commit 78c2774

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ extension OrderListViewController: UITableViewDelegate {
639639
/// Provide an implementation to show cell swipe actions. Return `nil` to provide no action.
640640
///
641641
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
642+
/// Fetch the order view model and make sure the order is not marked as completed before proceeding.
643+
///
644+
guard let objectID = dataSource.itemIdentifier(for: indexPath),
645+
let cellViewModel = viewModel.cellViewModel(withID: objectID),
646+
cellViewModel.status != .completed else {
647+
return nil
648+
}
642649

643650
let markAsCompletedAction = UIContextualAction(style: .normal, title: Localization.markCompleted, handler: { _, _, completionHandler in
644651
print("Mark as completed triggered...")

0 commit comments

Comments
 (0)