Skip to content

Commit 2215ce8

Browse files
authored
Blaze: Fix issue dismissing product selector in the campaign list view (#16085)
2 parents ad10bf7 + 7ac4a97 commit 2215ce8

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
23.2
55
-----
6+
- [*] Blaze: Fixed issue dismissing the Blaze flow from an empty campaign list. [https://github.com/woocommerce/woocommerce-ios/pull/16085]
67
- [*] POS: Enhanced cash payment experience with pre-filled amounts. [https://github.com/woocommerce/woocommerce-ios/pull/16058]
78
- [*] POS: Point of Sale settings are now accessible in POS mode [https://github.com/woocommerce/woocommerce-ios/pull/16067]
89

WooCommerce/Classes/ViewRelated/Blaze/BlazeCampaignList/BlazeCampaignListView.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ final class BlazeCampaignListHostingController: UIHostingController<BlazeCampaig
3232
super.init(rootView: BlazeCampaignListView(viewModel: viewModel))
3333

3434
rootView.onCreateCampaign = { [weak self] productID in
35-
self?.startCampaignCreation(productID: productID)
35+
self?.startCampaignCoordinator(productID: productID)
36+
}
37+
38+
rootView.onShowIntro = { [weak self] in
39+
guard self?.coordinator == nil else { return }
40+
self?.startCampaignCoordinator(showsIntro: true)
3641
}
3742
}
3843

@@ -45,14 +50,14 @@ final class BlazeCampaignListHostingController: UIHostingController<BlazeCampaig
4550
super.viewDidAppear(animated)
4651
if startsCampaignCreationOnAppear {
4752
startsCampaignCreationOnAppear = false
48-
startCampaignCreation()
53+
startCampaignCoordinator()
4954
}
5055
}
5156
}
5257

5358
/// Private helper
5459
private extension BlazeCampaignListHostingController {
55-
func startCampaignCreation(productID: Int64? = nil) {
60+
func startCampaignCoordinator(productID: Int64? = nil, showsIntro: Bool = false) {
5661
guard let navigationController else {
5762
return
5863
}
@@ -61,7 +66,7 @@ private extension BlazeCampaignListHostingController {
6166
siteURL: viewModel.siteURL,
6267
productID: productID,
6368
source: .campaignList,
64-
shouldShowIntro: viewModel.shouldShowIntroView,
69+
shouldShowIntro: showsIntro,
6570
navigationController: navigationController,
6671
onCampaignCreated: { [weak self] in
6772
self?.viewModel.didCreateCampaign()
@@ -104,6 +109,7 @@ struct BlazeCampaignListView: View {
104109
@ObservedObject private var viewModel: BlazeCampaignListViewModel
105110

106111
var onCreateCampaign: (Int64?) -> Void = { _ in }
112+
var onShowIntro: () -> Void = {}
107113

108114
init(viewModel: BlazeCampaignListViewModel) {
109115
self.viewModel = viewModel
@@ -155,9 +161,12 @@ struct BlazeCampaignListView: View {
155161
}) { url in
156162
detailView(url: url)
157163
}
158-
.onChange(of: viewModel.shouldShowIntroView) { shouldShow in
164+
.onChange(of: viewModel.shouldShowIntroView) { _, shouldShow in
165+
/// Hack: since the campaign creation coordinator takes care of the intro modal,
166+
/// the view triggers creating coordinator in the hosting controller
167+
/// and manually sets shouldShowIntroView to false.
159168
if shouldShow {
160-
onCreateCampaign(nil)
169+
onShowIntro()
161170
viewModel.shouldShowIntroView = false
162171
}
163172
}

0 commit comments

Comments
 (0)