Skip to content

WIP: Extract card reader connection state management from App to Yosemite #12723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

jaclync
Copy link
Contributor

@jaclync jaclync commented May 14, 2024

Closes: #

Description

Testing instructions

Screenshots


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added the type: technical debt Represents or solves tech debt of the project. label May 14, 2024
@jaclync jaclync added this to the 18.8 milestone May 14, 2024
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr12723-e83c70c
Version18.6
Bundle IDcom.automattic.alpha.woocommerce
Commite83c70c
App Center BuildWooCommerce - Prototype Builds #9040
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@@ -1,13 +1,68 @@
import Combine
import Foundation
import UIKit
import Storage
import SwiftUI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also remove the SwiftUI import from here to assure that we have no UI-related stuff going on, at the moment it still compiles fine when we do 👍

import Storage
import SwiftUI
import Yosemite

public enum CardReaderConnectionResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is from before, but should we use a different name for this enum? *Result implies there's a result type to be expected, which is not the case, and later we find signatures like:

private var onCompletion: ((Result<CardReaderConnectionResult, Error>) -> Void)?

Perhaps something like CardReaderConnectionStatus?

Comment on lines -138 to -139
alertsPresenter: CardPresentPaymentAlertsPresenting,
alertsProvider: BluetoothReaderConnnectionAlertsProviding,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Comment on lines 198 to 202
state = .idle
knownCardReaderProvider = knownReaderProvider
self.alertsPresenter = alertsPresenter
self.alertsProvider = alertsProvider
foundReaders = []
knownReaderID = nil
skippedReaderIDs = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're cleaning up the init here, maybe those should also go into some sort of "initial state" function?


/// Facilitates connecting to a card reader
///
final class CardReaderConnectionController {
public class CardReaderConnectionController {
public enum UIState {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This state machine here is looking great, I'd say ultimately since this is in Yosemite it shouldn't reference the UI in any manner, but some sort of CardReaderConnectionState instead. Then when we switch over the different cases in WooCommerce via connectionUIStateSubscription = controller.$cardReaderState is where we perform the specific calls to the alerts presenter which handles the UI bit

@jaclync
Copy link
Contributor Author

jaclync commented May 20, 2024

Thanks a lot for the feedback Gabriel, I agree with the suggestions and there is still a bunch of testing to be done. Though given the recent direction from leadership to not make significant changes that can affect the existing app, this PR seems unlikely to have a green light. I'm closing this PR for now but it'd be great to separate the UI logic if we have a chance in the future.

@jaclync jaclync closed this May 20, 2024
@jaclync jaclync deleted the feat/reader-connection-move-to-yosemite branch June 6, 2024 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: technical debt Represents or solves tech debt of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants