Skip to content

Commit 9f5de33

Browse files
committed
Auto connect to a known reader discovered after an unknown one
1 parent 9ba584a commit 9f5de33

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

WooCommerce/Classes/ViewRelated/CardPresentPayments/CardReaderConnectionController.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,17 @@ private extension CardReaderConnectionController {
308308
return
309309
}
310310

311-
/// If we enter this state and we already have found readers
311+
/// If we enter this state and another reader was discovered while the
312+
/// "Do you want to connect to" modal was being displayed and if that reader
313+
/// is known and the merchant tapped keep searching on the first
314+
/// (unknown) reader, auto-connect to that known reader
315+
if self.getFoundKnownReaders().isNotEmpty {
316+
self.candidateReader = self.getFoundKnownReaders().first
317+
self.state = .connectToReader
318+
return
319+
}
320+
321+
/// If we already have found readers
312322
/// display the list view if so enabled, or...
313323
///
314324
if showSeveralFoundReaders {
@@ -325,7 +335,8 @@ private extension CardReaderConnectionController {
325335
return
326336
}
327337

328-
/// Otherwise, display the "scanning" modal
338+
/// If all else fails, display the "scanning" modal and
339+
/// stay in this state
329340
///
330341
alerts.scanningForReader(from: from, cancel: {
331342
self.state = .cancel

0 commit comments

Comments
 (0)