Skip to content

Commit 167e76b

Browse files
Merge pull request #7769 from woocommerce/feature/7547-wrong-account-help-center-from-alert
Help button in fancy alert in "Wrong WordPress.com account error" screen
2 parents 43597e2 + de51a0a commit 167e76b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-----
55

66
- [*] Fixed a rare crash when selecting a store in the store picker. [https://github.com/woocommerce/woocommerce-ios/pull/7765]
7-
- [*] Help center: Added help center web page with FAQs for "Not a WooCommerce site" error screen. [https://github.com/woocommerce/woocommerce-ios/pull/7767]
7+
- [*] Help center: Added help center web page with FAQs for "Not a WooCommerce site" and "Wrong WordPress.com account" error screens. [https://github.com/woocommerce/woocommerce-ios/pull/7767, https://github.com/woocommerce/woocommerce-ios/pull/7769]
88

99
10.5
1010
-----

WooCommerce/Classes/Authentication/Navigation Exceptions/WrongAccountErrorViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ final class WrongAccountErrorViewModel: ULAccountMismatchViewModel {
156156
}
157157

158158
func didTapAuxiliaryButton(in viewController: UIViewController?) {
159-
let fancyAlert = FancyAlertViewController.makeNeedHelpFindingEmailAlertController()
159+
let fancyAlert = FancyAlertViewController.makeNeedHelpFindingEmailAlertController(screen: .wrongAccountError)
160160
fancyAlert.modalPresentationStyle = .custom
161161
fancyAlert.transitioningDelegate = AppDelegate.shared.tabBarController
162162
viewController?.present(fancyAlert, animated: true)

WooCommerce/Classes/ViewRelated/Fancy Alerts/FancyAlertViewController+UnifiedLogin.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import WordPressUI
22
import SafariServices
3+
import WordPressAuthenticator
34

45
extension FancyAlertViewController {
56
static func makeWhatIsJetpackAlertController(analytics: Analytics) -> FancyAlertViewController {
@@ -21,9 +22,10 @@ extension FancyAlertViewController {
2122
return controller
2223
}
2324

24-
static func makeNeedHelpFindingEmailAlertController() -> FancyAlertViewController {
25+
static func makeNeedHelpFindingEmailAlertController(screen: CustomHelpCenterContent.Screen? = nil) -> FancyAlertViewController {
2526
let dismissButton = makeDismissButtonConfig()
26-
let moreHelpButton = makeNeedMoreHelpButton()
27+
let customHelpCenterContent = screen.map { CustomHelpCenterContent(screen: $0, flow: AuthenticatorAnalyticsTracker.shared.state.lastFlow) }
28+
let moreHelpButton = makeNeedMoreHelpButton(customHelpCenterContent: customHelpCenterContent)
2729
let config = FancyAlertViewController.Config(titleText: Localization.whatEmailDoIUse,
2830
bodyText: Localization.whatEmailDoIUseLongDescription,
2931
headerImage: nil,
@@ -108,14 +110,20 @@ private extension FancyAlertViewController {
108110
}
109111
}
110112

111-
static func makeNeedMoreHelpButton() -> FancyAlertViewController.Config.ButtonConfig {
113+
static func makeNeedMoreHelpButton(customHelpCenterContent: CustomHelpCenterContent? = nil) -> FancyAlertViewController.Config.ButtonConfig {
112114
return FancyAlertViewController.Config.ButtonConfig(Localization.needMoreHelp) { controller, _ in
113115
let identifier = HelpAndSupportViewController.classNameWithoutNamespaces
114-
guard let supportViewController = UIStoryboard
115-
.dashboard
116-
.instantiateViewController(withIdentifier: identifier) as? HelpAndSupportViewController else {
117-
return
118-
}
116+
let supportViewController = UIStoryboard.dashboard.instantiateViewController(identifier: identifier,
117+
creator: { coder -> HelpAndSupportViewController? in
118+
guard let customHelpCenterContent = customHelpCenterContent else {
119+
/// Returning nil as we don't need to customise the HelpAndSupportViewController
120+
/// In this case `instantiateViewController` method will use the default `HelpAndSupportViewController` created from storyboard.
121+
///
122+
return nil
123+
}
124+
125+
return HelpAndSupportViewController(customHelpCenterContent: customHelpCenterContent, coder: coder)
126+
})
119127

120128
supportViewController.displaysDismissAction = true
121129

0 commit comments

Comments
 (0)