From 14a8841d786386acd8f471b2cc9a823ce8a32f63 Mon Sep 17 00:00:00 2001 From: Josh Heald Date: Tue, 28 Jan 2025 09:53:54 +0000 Subject: [PATCH] 14992 Publish all reader status changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we get a reader status change from the underlying `CardPresentPaymentStore`, we should always republish that to POS. Previously, we would treat empty arrays of readers from the store (nil in the `connectedReaderPublisher`) as something we don’t have to pass on, when in reality they likely represent a disconnection originating outside the app (e.g. turning the reader off, bluetooth failure, or the battery running out.) This commit updates the handling to treat these cases as a `disconnected` reader, so now the UI will update accordingly. --- .../CardPresentPaymentService.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentService.swift b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentService.swift index b72e711c172..bdb788ef2ae 100644 --- a/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentService.swift +++ b/WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentService.swift @@ -64,14 +64,12 @@ final class CardPresentPaymentService: CardPresentPaymentFacade { self.connectedReaderPublisher = connectedReaderPublisher readerConnectionStatusPublisher = connectedReaderPublisher - .map({ reader -> CardPresentPaymentReaderConnectionStatus? in - if let reader { - return .connected(reader) - } else { - return nil + .map({ reader -> CardPresentPaymentReaderConnectionStatus in + guard let reader else { + return .disconnected } + return .connected(reader) }) - .compactMap { $0 } .merge(with: paymentAlertsPresenterAdaptor.readerConnectionStatusPublisher) .merge(with: readerConnectionStatusSubject) .receive(on: DispatchQueue.main)