File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ final class CardReaderSupportDeterminer: CardReaderSupportDetermining {
1616 private let configuration : CardPresentPaymentsConfiguration
1717 private let siteID : Int64
1818 private var locationManager : CLLocationManager = CLLocationManager ( )
19+ private static var deviceSupportsLocalMobileReader : [ Int64 : Bool ] = [ : ]
1920
2021 init ( siteID: Int64 ,
2122 configuration: CardPresentPaymentsConfiguration = CardPresentConfigurationLoader ( ) . configuration,
@@ -59,7 +60,16 @@ final class CardReaderSupportDeterminer: CardReaderSupportDetermining {
5960
6061 @MainActor
6162 func deviceSupportsLocalMobileReader( ) async -> Bool {
62- await withCheckedContinuation { continuation in
63+ /// There may be crashes due to multiple consecutive calls checkDeviceSupport
64+ /// Local mobile reader (Tap to Pay) support shouldn't change during the app lifecycle
65+ /// Only a change in operating system version can affect it which would require a restart of the app
66+ ///
67+ if let cachedResult = Self . deviceSupportsLocalMobileReader [ siteID] {
68+ return cachedResult
69+ }
70+
71+
72+ let deviceSupportsLocalMobileReader = await withCheckedContinuation { continuation in
6373 let action = CardPresentPaymentAction . checkDeviceSupport (
6474 siteID: siteID,
6575 cardReaderType: . appleBuiltIn,
@@ -69,6 +79,9 @@ final class CardReaderSupportDeterminer: CardReaderSupportDetermining {
6979 }
7080 stores. dispatch ( action)
7181 }
82+
83+ Self . deviceSupportsLocalMobileReader [ siteID] = deviceSupportsLocalMobileReader
84+ return deviceSupportsLocalMobileReader
7285 }
7386
7487 @MainActor
You can’t perform that action at this time.
0 commit comments