From dcdcd42380c0f1cf266610f6427599ad4dd744df Mon Sep 17 00:00:00 2001 From: Povilas Staskus <4062343+staskus@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:08:22 +0100 Subject: [PATCH 1/2] Show a modal that opens bluetooth settings after bluetoothDenied errors --- .../BluetoothReaderConnectionAlertsProvider.swift | 9 ++++++++- .../CardReadersV2/CardReaderSettingsAlerts.swift | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift index f2190712ddb..12b810913a2 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift @@ -1,4 +1,6 @@ import Foundation +import Yosemite +import Hardware import UIKit struct BluetoothReaderConnectionAlertsProvider: BluetoothReaderConnnectionAlertsProviding { @@ -9,7 +11,12 @@ struct BluetoothReaderConnectionAlertsProvider: BluetoothReaderConnnectionAlerts func scanningFailed(error: Error, close: @escaping () -> Void) -> CardPresentPaymentsModalViewModel { - CardPresentModalScanningFailed(error: error, primaryAction: close) + switch error { + case CardReaderServiceError.bluetoothDenied, CardReaderServiceError.discovery(underlyingError: .bluetoothDenied): + return CardPresentModalBluetoothRequired(error: error, primaryAction: close) + default: + return CardPresentModalScanningFailed(error: error, primaryAction: close) + } } func connectingToReader() -> CardPresentPaymentsModalViewModel { diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift index 26f0772d0bb..d60b041f438 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift @@ -1,5 +1,6 @@ import UIKit import Yosemite +import Hardware import WordPressUI /// A layer of indirection between our card reader settings view controllers and the modal alerts @@ -176,7 +177,7 @@ private extension CardReaderSettingsAlerts { func scanningFailed(error: Error, close: @escaping () -> Void) -> CardPresentPaymentsModalViewModel { switch error { - case CardReaderServiceError.bluetoothDenied: + case CardReaderServiceError.bluetoothDenied, CardReaderServiceError.discovery(underlyingError: .bluetoothDenied): return CardPresentModalBluetoothRequired(error: error, primaryAction: close) default: return CardPresentModalScanningFailed(error: error, primaryAction: close) From 5edfeb9c96a649773c6e370353f6ac3698135383 Mon Sep 17 00:00:00 2001 From: Povilas Staskus <4062343+staskus@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:29:15 +0100 Subject: [PATCH 2/2] Remove references to Hardware --- .../CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift | 1 - .../Settings/CardReadersV2/CardReaderSettingsAlerts.swift | 1 - 2 files changed, 2 deletions(-) diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift index 12b810913a2..bf3b57e1908 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/BluetoothReaderConnectionAlertsProvider.swift @@ -1,6 +1,5 @@ import Foundation import Yosemite -import Hardware import UIKit struct BluetoothReaderConnectionAlertsProvider: BluetoothReaderConnnectionAlertsProviding { diff --git a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift index d60b041f438..aa5d4cdec2e 100644 --- a/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift +++ b/WooCommerce/Classes/ViewRelated/Dashboard/Settings/CardReadersV2/CardReaderSettingsAlerts.swift @@ -1,6 +1,5 @@ import UIKit import Yosemite -import Hardware import WordPressUI /// A layer of indirection between our card reader settings view controllers and the modal alerts