Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit d0b3c02

Browse files
authored
Merge pull request #4 from wordpress-mobile/remove_helpshift_code_nux_view_controllers
Remove Helpshift code from NUX View Controllers
2 parents dec4d5f + 968d7b6 commit d0b3c02

11 files changed

+19
-130
lines changed

WordPressAuthenticator.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
B56052A42090B2ED001B91FD /* CircularImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56052A32090B2ED001B91FD /* CircularImageView.swift */; };
1818
B56090C6208A4F5400399AE4 /* NUXButtonViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090B8208A4F5300399AE4 /* NUXButtonViewController.swift */; };
1919
B56090C7208A4F5400399AE4 /* NUXKeyboardResponder.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090B9208A4F5300399AE4 /* NUXKeyboardResponder.swift */; };
20-
B56090C8208A4F5400399AE4 /* NUXHelpBadgeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BA208A4F5300399AE4 /* NUXHelpBadgeLabel.swift */; };
2120
B56090C9208A4F5400399AE4 /* NUXLinkMailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BB208A4F5300399AE4 /* NUXLinkMailViewController.swift */; };
2221
B56090CA208A4F5400399AE4 /* NUXButtonView.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B56090BC208A4F5300399AE4 /* NUXButtonView.storyboard */; };
2322
B56090CB208A4F5400399AE4 /* NUXNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B56090BD208A4F5400399AE4 /* NUXNavigationController.swift */; };
@@ -145,7 +144,6 @@
145144
B56052A32090B2ED001B91FD /* CircularImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularImageView.swift; sourceTree = "<group>"; };
146145
B56090B8208A4F5300399AE4 /* NUXButtonViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXButtonViewController.swift; sourceTree = "<group>"; };
147146
B56090B9208A4F5300399AE4 /* NUXKeyboardResponder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXKeyboardResponder.swift; sourceTree = "<group>"; };
148-
B56090BA208A4F5300399AE4 /* NUXHelpBadgeLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXHelpBadgeLabel.swift; sourceTree = "<group>"; };
149147
B56090BB208A4F5300399AE4 /* NUXLinkMailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXLinkMailViewController.swift; sourceTree = "<group>"; };
150148
B56090BC208A4F5300399AE4 /* NUXButtonView.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NUXButtonView.storyboard; sourceTree = "<group>"; };
151149
B56090BD208A4F5400399AE4 /* NUXNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NUXNavigationController.swift; sourceTree = "<group>"; };
@@ -351,7 +349,6 @@
351349
B56090BC208A4F5300399AE4 /* NUXButtonView.storyboard */,
352350
B56090B8208A4F5300399AE4 /* NUXButtonViewController.swift */,
353351
B56090C1208A4F5400399AE4 /* NUXCollectionViewController.swift */,
354-
B56090BA208A4F5300399AE4 /* NUXHelpBadgeLabel.swift */,
355352
B56090B9208A4F5300399AE4 /* NUXKeyboardResponder.swift */,
356353
B56090C5208A4F5400399AE4 /* NUXLinkAuthViewController.swift */,
357354
B56090BB208A4F5300399AE4 /* NUXLinkMailViewController.swift */,
@@ -827,7 +824,6 @@
827824
B56090C9208A4F5400399AE4 /* NUXLinkMailViewController.swift in Sources */,
828825
B56090F1208A527000399AE4 /* String+Underline.swift in Sources */,
829826
B56052A42090B2ED001B91FD /* CircularImageView.swift in Sources */,
830-
B56090C8208A4F5400399AE4 /* NUXHelpBadgeLabel.swift in Sources */,
831827
B5609141208A563800399AE4 /* LoginPrologueViewController.swift in Sources */,
832828
B56090EB208A51D000399AE4 /* LoginFields.swift in Sources */,
833829
B56090FB208A533200399AE4 /* WordPressSupportSourceTag.swift in Sources */,

WordPressAuthenticator/Authenticator/WordPressAuthenticator+Notifications.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ extension NSNotification.Name {
99
///
1010
public static let wordpressLoginFinishedJetpackLogin = Foundation.Notification.Name(rawValue: "WordPressLoginFinishedJetpackLogin")
1111

12-
/// Posted whenever the Support Badge needs to be updated.
13-
///
14-
public static let wordpressSupportBadgeUpdated = NSNotification.Name(rawValue: "WordPressSupportBadgeUpdated")
15-
1612
/// Posted whenever a Support notification is received.
1713
///
1814
public static let wordpressSupportNotificationReceived = NSNotification.Name(rawValue: "WordPressSupportNotificationReceived")

WordPressAuthenticator/Authenticator/WordPressAuthenticator.swift

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ public protocol WordPressAuthenticatorDelegate: class {
4949
///
5050
var supportEnabled: Bool { get }
5151

52-
/// Returns the Support's Badge Count.
53-
///
54-
var supportBadgeCount: Int { get }
55-
5652
/// Signals the Host App that a new WordPress.com account has just been created.
5753
///
5854
/// - Parameters:
@@ -62,10 +58,9 @@ public protocol WordPressAuthenticatorDelegate: class {
6258
///
6359
func createdWordPressComAccount(username: String, authToken: String)
6460

65-
/// Presents the Support new request, from a given ViewController, with a specified SourceTag, and additional metadata,
66-
/// such as all of the User's Login details.
61+
/// Presents the Support new request, from a given ViewController, with a specified SourceTag.
6762
///
68-
func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag, options: [String: Any])
63+
func presentSupportRequest(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag)
6964

7065
/// Presents the Login Epilogue, in the specified NavigationController.
7166
///
@@ -77,11 +72,7 @@ public protocol WordPressAuthenticatorDelegate: class {
7772

7873
/// Presents the Support Interface from a given ViewController, with a specified SourceTag.
7974
///
80-
func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag, options: [String: Any])
81-
82-
/// Refreshes Support's Badge Count.
83-
///
84-
func refreshSupportBadgeCount()
75+
func presentSupport(from sourceViewController: UIViewController, sourceTag: WordPressSupportSourceTag)
8576

8677
/// Indicates if the Login Epilogue should be displayed.
8778
///
@@ -146,10 +137,6 @@ public struct WordPressAuthenticatorConfiguration {
146137
/// UserAgent
147138
///
148139
let userAgent: String
149-
150-
/// Used to determine which view to use for new Support notifications.
151-
///
152-
let supportNotificationIndicatorFeatureFlag: Bool
153140

154141
/// Designated Initializer
155142
///
@@ -159,16 +146,14 @@ public struct WordPressAuthenticatorConfiguration {
159146
wpcomTermsOfServiceURL: String,
160147
googleLoginClientId: String,
161148
googleLoginServerClientId: String,
162-
userAgent: String,
163-
supportNotificationIndicatorFeatureFlag: Bool) {
149+
userAgent: String) {
164150
self.wpcomClientId = wpcomClientId
165151
self.wpcomSecret = wpcomSecret
166152
self.wpcomScheme = wpcomScheme
167153
self.wpcomTermsOfServiceURL = wpcomTermsOfServiceURL
168154
self.googleLoginClientId = googleLoginClientId
169155
self.googleLoginServerClientId = googleLoginServerClientId
170156
self.userAgent = userAgent
171-
self.supportNotificationIndicatorFeatureFlag = supportNotificationIndicatorFeatureFlag
172157
}
173158
}
174159

@@ -232,10 +217,6 @@ public struct WordPressAuthenticatorConfiguration {
232217
}
233218

234219
// MARK: - Public Methods
235-
236-
public func supportBadgeCountWasUpdated() {
237-
NotificationCenter.default.post(name: .wordpressSupportBadgeUpdated, object: nil)
238-
}
239220

240221
public func supportPushNotificationReceived() {
241222
NotificationCenter.default.post(name: .wordpressSupportNotificationReceived, object: nil)

WordPressAuthenticator/Extensions/FancyAlertViewController+LoginError.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension FancyAlertViewController {
3030
return
3131
}
3232

33-
WordPressAuthenticator.shared.delegate?.presentSupportRequest(from: viewController, sourceTag: sourceTag, options: loginFields.helpshiftLoginOptions())
33+
WordPressAuthenticator.shared.delegate?.presentSupportRequest(from: viewController, sourceTag: sourceTag)
3434
}
3535
}
3636

@@ -73,13 +73,13 @@ extension FancyAlertViewController {
7373
if WordPressAuthenticator.shared.delegate?.supportEnabled == true {
7474
// TODO: Placeholder Jetpack login error message. Needs updating with final wording. 2017-06-15 Aerych.
7575
message = NSLocalizedString("We're not able to connect to the Jetpack site at that URL. Contact us for assistance.", comment: "Error message shown when having trouble connecting to a Jetpack site.")
76-
return alertForGenericErrorMessageWithHelpshiftButton(message, loginFields: loginFields, sourceTag: sourceTag)
76+
return alertForGenericErrorMessageWithHelpButton(message, loginFields: loginFields, sourceTag: sourceTag)
7777
}
7878
}
7979

8080
if error.domain != WPXMLRPCFaultErrorDomain && error.code != NSURLErrorBadURL {
8181
if WordPressAuthenticator.shared.delegate?.supportEnabled == true {
82-
return alertForGenericErrorMessageWithHelpshiftButton(message, loginFields: loginFields, sourceTag: sourceTag)
82+
return alertForGenericErrorMessageWithHelpButton(message, loginFields: loginFields, sourceTag: sourceTag)
8383
}
8484

8585
return alertForGenericErrorMessage(message, loginFields: loginFields, sourceTag: sourceTag)
@@ -114,8 +114,7 @@ extension FancyAlertViewController {
114114
return
115115
}
116116

117-
let options = loginFields.helpshiftLoginOptions()
118-
authDelegate.presentSupport(from: sourceViewController, sourceTag: sourceTag, options: options)
117+
authDelegate.presentSupport(from: sourceViewController, sourceTag: sourceTag)
119118
}
120119
}
121120

@@ -133,12 +132,12 @@ extension FancyAlertViewController {
133132

134133

135134
/// Shows a generic error message. The view
136-
/// is configured so the user can open Helpshift for assistance.
135+
/// is configured so the user can open Support for assistance.
137136
///
138137
/// - Parameter message: The error message to show.
139138
/// - Parameter sourceTag: tag of the source of the error
140139
///
141-
static func alertForGenericErrorMessageWithHelpshiftButton(_ message: String, loginFields: LoginFields, sourceTag: WordPressSupportSourceTag) -> FancyAlertViewController {
140+
static func alertForGenericErrorMessageWithHelpButton(_ message: String, loginFields: LoginFields, sourceTag: WordPressSupportSourceTag) -> FancyAlertViewController {
142141
let moreHelpButton = ButtonConfig(Strings.moreHelp) { controller, _ in
143142
controller.dismiss(animated: true) {
144143
// Find the topmost view controller that we can present from
@@ -150,7 +149,7 @@ extension FancyAlertViewController {
150149
return
151150
}
152151

153-
WordPressAuthenticator.shared.delegate?.presentSupportRequest(from: viewController, sourceTag: sourceTag, options: loginFields.helpshiftLoginOptions())
152+
WordPressAuthenticator.shared.delegate?.presentSupportRequest(from: viewController, sourceTag: sourceTag)
154153
}
155154
}
156155

WordPressAuthenticator/Model/LoginFields.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ public class LoginFields: NSObject {
3838
@objc public var meta = LoginFieldsMeta()
3939
var storedCredentials: SafariStoredCredentials?
4040

41-
42-
/// Returns a dictionary of login related data to include with a Helpshift session.
43-
/// Used to help diagnose trouble reports via helpshift.
44-
///
45-
@objc func helpshiftLoginOptions() -> [String: Any] {
46-
return [
47-
"Source": "Login",
48-
"Username": username,
49-
"SiteURL": siteAddress,
50-
]
51-
}
52-
5341
/// Convenience method for persisting stored credentials.
5442
///
5543
@objc func setStoredCredentials(usernameHash: Int, passwordHash: Int) {

WordPressAuthenticator/NUX/NUXCollectionViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ open class NUXCollectionViewController: UICollectionViewController, NUXViewContr
55
// MARK: NUXViewControllerBase properties
66
/// these properties comply with NUXViewControllerBase and are duplicated with NUXTableViewController
77
public var helpNotificationIndicator: WPHelpIndicatorView = WPHelpIndicatorView()
8-
public var helpBadge: NUXHelpBadgeLabel = NUXHelpBadgeLabel()
98
public var helpButton: UIButton = UIButton(type: .custom)
109
public var dismissBlock: ((_ cancelled: Bool) -> Void)?
1110
public var loginFields = LoginFields()

WordPressAuthenticator/NUX/NUXHelpBadgeLabel.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.

WordPressAuthenticator/NUX/NUXTableViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ open class NUXTableViewController: UITableViewController, NUXViewControllerBase,
55
// MARK: NUXViewControllerBase properties
66
/// these properties comply with NUXViewControllerBase and are duplicated with NUXTableViewController
77
public var helpNotificationIndicator: WPHelpIndicatorView = WPHelpIndicatorView()
8-
public var helpBadge: NUXHelpBadgeLabel = NUXHelpBadgeLabel()
98
public var helpButton: UIButton = UIButton(type: .custom)
109
public var dismissBlock: ((_ cancelled: Bool) -> Void)?
1110
public var loginFields = LoginFields()

WordPressAuthenticator/NUX/NUXViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ open class NUXViewController: UIViewController, NUXViewControllerBase, UIViewCon
99
// MARK: NUXViewControllerBase properties
1010
/// these properties comply with NUXViewControllerBase and are duplicated with NUXTableViewController
1111
public var helpNotificationIndicator: WPHelpIndicatorView = WPHelpIndicatorView()
12-
public var helpBadge: NUXHelpBadgeLabel = NUXHelpBadgeLabel()
1312
public var helpButton: UIButton = UIButton(type: .custom)
1413
public var dismissBlock: ((_ cancelled: Bool) -> Void)?
1514
public var loginFields = LoginFields()

WordPressAuthenticator/NUX/NUXViewControllerBase.swift

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@ private enum Constants {
99
static let helpButtonItemMinimumSize = CGSize(width: 44.0, height: 44.0)
1010

1111
static let notificationIndicatorCenterOffset = CGPoint(x: 5, y: 12)
12-
static var notificationIndicatorSize: CGSize {
13-
if WordPressAuthenticator.shared.configuration.supportNotificationIndicatorFeatureFlag == true {
14-
return CGSize(width: 10, height: 10)
15-
} else {
16-
return CGSize(width: 12, height: 12)
17-
}
18-
}
12+
static var notificationIndicatorSize = CGSize(width: 10, height: 10)
1913
}
2014

2115
/// base protocol for NUX view controllers
2216
public protocol NUXViewControllerBase {
2317
var sourceTag: WordPressSupportSourceTag { get }
24-
var helpBadge: NUXHelpBadgeLabel { get }
2518
var helpNotificationIndicator: WPHelpIndicatorView { get }
2619
var helpButton: UIButton { get }
2720
var loginFields: LoginFields { get }
@@ -88,7 +81,7 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
8881
///
8982
public func displayErrorAlert(_ message: String, sourceTag: WordPressSupportSourceTag) {
9083
let presentingController = navigationController ?? self
91-
let controller = FancyAlertViewController.alertForGenericErrorMessageWithHelpshiftButton(message, loginFields: loginFields, sourceTag: sourceTag)
84+
let controller = FancyAlertViewController.alertForGenericErrorMessageWithHelpButton(message, loginFields: loginFields, sourceTag: sourceTag)
9285
controller.modalPresentationStyle = .custom
9386
controller.transitioningDelegate = self
9487
presentingController.present(controller, animated: true, completion: nil)
@@ -113,14 +106,8 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
113106

114107
// MARK: - Notifications
115108

116-
/// Updates the badge count and its visibility.
109+
/// Updates the notification indicatorand its visibility.
117110
///
118-
func refreshSupportBadge() {
119-
let count = WordPressAuthenticator.shared.delegate?.supportBadgeCount ?? 0
120-
helpBadge.text = "\(count)"
121-
helpBadge.isHidden = (count == 0)
122-
}
123-
124111
func refreshSupportNotificationIndicator() {
125112
let showIndicator = WordPressAuthenticator.shared.delegate?.showSupportNotificationIndicator ?? false
126113
helpNotificationIndicator.isHidden = !showIndicator
@@ -171,7 +158,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
171158
}
172159

173160
addHelpButtonToNavController()
174-
refreshSupportBadge()
175161
refreshSupportNotificationIndicator()
176162
}
177163

@@ -219,23 +205,11 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
219205
helpButton.bottomAnchor.constraint(equalTo: superView.bottomAnchor).isActive = true
220206
}
221207

222-
// MARK: Badge settings
208+
// MARK: Notification Indicator settings
223209

224210
private func addNotificationIndicatorView(to superView: UIView) {
225-
if WordPressAuthenticator.shared.configuration.supportNotificationIndicatorFeatureFlag == true {
226-
setupNotificationsIndicator()
227-
layoutNotificationIndicatorView(helpNotificationIndicator, to: superView)
228-
} else {
229-
setupBadge()
230-
layoutNotificationIndicatorView(helpBadge, to: superView)
231-
}
232-
}
233-
234-
private func setupBadge() {
235-
helpBadge.isHidden = true
236-
NotificationCenter.default.addObserver(forName: .wordpressSupportBadgeUpdated, object: nil, queue: nil) { [weak self] _ in
237-
self?.refreshSupportBadge()
238-
}
211+
setupNotificationsIndicator()
212+
layoutNotificationIndicatorView(helpNotificationIndicator, to: superView)
239213
}
240214

241215
private func setupNotificationsIndicator() {
@@ -275,6 +249,6 @@ extension NUXViewControllerBase where Self: UIViewController, Self: UIViewContro
275249
fatalError()
276250
}
277251

278-
WordPressAuthenticator.shared.delegate?.presentSupport(from: navigationController, sourceTag: source, options: [:])
252+
WordPressAuthenticator.shared.delegate?.presentSupport(from: navigationController, sourceTag: source)
279253
}
280254
}

0 commit comments

Comments
 (0)