Skip to content

Commit 43ab0aa

Browse files
authored
Merge pull request #7544 from woocommerce/issue/7541-save-plugin-selection-regardless-of-onboarding-failures
[Mobile Payments] Save plugin selection on onboarding completion
2 parents 27a3248 + f3d8bed commit 43ab0aa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
10.1
44
-----
55
- [*] In-Person Payments: The onboarding notice on the In-Person Payments menu is correctly dismissed after multiple prompts are shown. [https://github.com/woocommerce/woocommerce-ios/pull/7543]
6+
- [*] In-Person Payments: The plugin selection is saved correctly after multiple onboarding prompts. [https://github.com/woocommerce/woocommerce-ios/pull/7544]
67

78
10.0
89
-----

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/CardPresentPaymentsOnboardingUseCase.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU
4343
var statePublisher: Published<CardPresentPaymentOnboardingState>.Publisher {
4444
$state
4545
}
46+
private var cancellables: [AnyCancellable] = []
4647

4748
init(
4849
storageManager: StorageManagerType = ServiceLocator.storageManager,
@@ -103,11 +104,19 @@ final class CardPresentPaymentsOnboardingUseCase: CardPresentPaymentsOnboardingU
103104
assert(state.isSelectPlugin)
104105

105106
preferredPluginLocal = selectedPlugin
107+
deferredSaveSelectedPluginWhenOnboardingComplete(selectedPlugin: selectedPlugin)
108+
106109
updateState()
107-
if case .completed(let pluginState) = state,
108-
pluginState.preferred == selectedPlugin {
109-
savePreferredPlugin(selectedPlugin)
110+
}
111+
112+
private func deferredSaveSelectedPluginWhenOnboardingComplete(selectedPlugin: CardPresentPaymentsPlugin) {
113+
$state.share().sink { [weak self] newState in
114+
if case .completed(let pluginState) = newState,
115+
pluginState.preferred == selectedPlugin {
116+
self?.savePreferredPlugin(selectedPlugin)
117+
}
110118
}
119+
.store(in: &cancellables)
111120
}
112121

113122
func clearPluginSelection() {

0 commit comments

Comments
 (0)