From e360fa443f4add5555bb723ca6fa4811ef704b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Sat, 31 Jul 2021 01:38:31 -0400 Subject: [PATCH] FIX: Issue: Apple Watch invoice gets stuck #1529 --- .../ReceiveInterfaceController.swift | 2 +- .../SpecifyInterfaceController.swift | 10 ++++++++-- .../WalletDetailsInterfaceController.swift | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift b/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift index 07729bac4..8d759e45d 100644 --- a/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift +++ b/ios/BlueWalletWatch Extension/ReceiveInterfaceController.swift @@ -55,7 +55,7 @@ class ReceiveInterfaceController: WKInterfaceController { self?.toggleViewButtonPressed() WCSession.default.sendMessage(["message": "fetchTransactions"], replyHandler: nil, errorHandler: nil) } else { - self?.presentAlert(withTitle: "Error", message: "Unable to create invoice. Please, make sure your iPhone is paired and nearby.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in + self?.presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in self?.dismiss() self?.pop() })]) diff --git a/ios/BlueWalletWatch Extension/SpecifyInterfaceController.swift b/ios/BlueWalletWatch Extension/SpecifyInterfaceController.swift index b6116408f..daf6e75b0 100644 --- a/ios/BlueWalletWatch Extension/SpecifyInterfaceController.swift +++ b/ios/BlueWalletWatch Extension/SpecifyInterfaceController.swift @@ -89,8 +89,14 @@ class SpecifyInterfaceController: WKInterfaceController { } @IBAction func createButtonTapped() { - NotificationCenter.default.post(name: NotificationName.createQRCode, object: specifiedQRContent) - dismiss() + if (WCSession.default.activationState == .activated) { + NotificationCenter.default.post(name: NotificationName.createQRCode, object: specifiedQRContent) + dismiss() + } else { + presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in + self?.dismiss() + })]) + } } override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? { diff --git a/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift b/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift index 9af9af2ec..a1eac4a43 100644 --- a/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift +++ b/ios/BlueWalletWatch Extension/WalletDetailsInterfaceController.swift @@ -92,7 +92,6 @@ class WalletDetailsInterfaceController: WKInterfaceController { transactionsTable.setHidden(wallet?.transactions.isEmpty ?? true) noTransactionsLabel.setHidden(!(wallet?.transactions.isEmpty ?? false)) receiveButton.setHidden(wallet?.receiveAddress.isEmpty ?? true) - createInvoiceButton.setEnabled(WCSession.default.isReachable) } @IBAction func receiveMenuItemTapped() { @@ -116,9 +115,13 @@ class WalletDetailsInterfaceController: WKInterfaceController { } @IBAction func createInvoiceTapped() { - if (WCSession.default.isReachable) { + if (WCSession.default.activationState == .activated) { pushController(withName: ReceiveInterfaceController.identifier, context: (wallet?.identifier, "createInvoice")) - } + } else { + presentAlert(withTitle: "Error", message: "Unable to create invoice. Please open BlueWallet on your iPhone and unlock your wallets.", preferredStyle: .alert, actions: [WKAlertAction(title: "OK", style: .default, handler: { [weak self] in + self?.dismiss() + })]) + } } override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {