@@ -26,7 +26,7 @@ open class JetpackConnectionViewController: UITableViewController {
2626 fileprivate var blog : Blog !
2727 fileprivate var service : BlogJetpackSettingsService !
2828 fileprivate lazy var handler : ImmuTableViewHandler = {
29- return ImmuTableViewHandler ( takeOver: self )
29+ ImmuTableViewHandler ( takeOver: self )
3030 } ( )
3131
3232 // MARK: - Public Properties
@@ -66,37 +66,53 @@ open class JetpackConnectionViewController: UITableViewController {
6666 }
6767
6868 func tableViewModel( ) -> ImmuTable {
69- let disconnectRow = DestructiveButtonRow ( title: NSLocalizedString ( " Disconnect from WordPress.com " ,
70- comment: " Disconnect from WordPress.com button " ) ,
71- action: self . disconnectJetpackTapped ( ) ,
72- accessibilityIdentifier: " disconnectFromWordPress.comButton " )
69+ let disconnectRow = DestructiveButtonRow (
70+ title: NSLocalizedString (
71+ " Disconnect from WordPress.com " ,
72+ comment: " Disconnect from WordPress.com button "
73+ ) ,
74+ action: self . disconnectJetpackTapped ( ) ,
75+ accessibilityIdentifier: " disconnectFromWordPress.comButton "
76+ )
7377 return ImmuTable ( sections: [
7478 ImmuTableSection (
7579 headerText: " " ,
7680 rows: [ disconnectRow] ,
77- footerText: NSLocalizedString ( " Your site will no longer send data to WordPress.com and Jetpack features will stop working. You will lose access to the site on the app and you will have to re-add it with the site credentials. " ,
78- comment: " Explanatory text bellow the Disconnect from WordPress.com button " )
81+ footerText: NSLocalizedString (
82+ " Your site will no longer send data to WordPress.com and Jetpack features will stop working. You will lose access to the site on the app and you will have to re-add it with the site credentials. " ,
83+ comment: " Explanatory text bellow the Disconnect from WordPress.com button "
84+ )
7985 )
8086 ] )
8187 }
8288
8389 // MARK: - Row Handler
8490
8591 func disconnectJetpackTapped( ) -> ImmuTableAction {
86- return { [ unowned self] _ in
92+ { [ unowned self] _ in
8793 self . tableView. deselectSelectedRowWithAnimation ( true )
88- let message = NSLocalizedString ( " Are you sure you want to disconnect Jetpack from the site? " ,
89- comment: " Message prompting the user to confirm that they want to disconnect Jetpack from the site. " )
90-
91- let alertController = UIAlertController ( title: nil ,
92- message: message,
93- preferredStyle: . alert)
94- alertController. addCancelActionWithTitle ( NSLocalizedString ( " Cancel " , comment: " Verb. A button title. Tapping cancels an action. " ) )
95- alertController. addDestructiveActionWithTitle ( NSLocalizedString ( " Disconnect " ,
96- comment: " Title for button that disconnects Jetpack from the site " ) ,
97- handler: { _ in
98- self . disconnectJetpack ( )
99- } )
94+ let message = NSLocalizedString (
95+ " Are you sure you want to disconnect Jetpack from the site? " ,
96+ comment: " Message prompting the user to confirm that they want to disconnect Jetpack from the site. "
97+ )
98+
99+ let alertController = UIAlertController (
100+ title: nil ,
101+ message: message,
102+ preferredStyle: . alert
103+ )
104+ alertController. addCancelActionWithTitle (
105+ NSLocalizedString ( " Cancel " , comment: " Verb. A button title. Tapping cancels an action. " )
106+ )
107+ alertController. addDestructiveActionWithTitle (
108+ NSLocalizedString (
109+ " Disconnect " ,
110+ comment: " Title for button that disconnects Jetpack from the site "
111+ ) ,
112+ handler: { _ in
113+ self . disconnectJetpack ( )
114+ }
115+ )
100116 WPAnalytics . trackEvent ( . jetpackDisconnectTapped)
101117 self . present ( alertController, animated: true )
102118 }
@@ -105,26 +121,32 @@ open class JetpackConnectionViewController: UITableViewController {
105121 @objc func disconnectJetpack( ) {
106122 WPAnalytics . trackEvent ( . jetpackDisconnectRequested)
107123 startLoading ( )
108- self . service. disconnectJetpackFromBlog ( self . blog,
109- success: { [ weak self] in
110- self ? . stopLoading ( )
111- if let blog = self ? . blog {
112- let service = BlogService ( coreDataStack: ContextManager . shared)
113- service. remove ( blog)
114- self ? . delegate? . jetpackDisconnectedForBlog ( blog)
115- } else {
116- self ? . dismiss ( )
117- }
118- } ,
119- failure: { [ weak self] error in
120- self ? . stopLoading ( )
121- let errorTitle = NSLocalizedString ( " Error disconnecting Jetpack " ,
122- comment: " Title of error dialog when disconnecting jetpack fails. " )
123- let errorMessage = NSLocalizedString ( " Please contact support for assistance. " ,
124- comment: " Message displayed on an error alert to prompt the user to contact support " )
125- WPError . showAlert ( withTitle: errorTitle, message: errorMessage, withSupportButton: true )
126- DDLogError ( " Error disconnecting Jetpack: \( String ( describing: error) ) " )
127- } )
124+ self . service. disconnectJetpackFromBlog (
125+ self . blog,
126+ success: { [ weak self] in
127+ self ? . stopLoading ( )
128+ if let blog = self ? . blog {
129+ let service = BlogService ( coreDataStack: ContextManager . shared)
130+ service. remove ( blog)
131+ self ? . delegate? . jetpackDisconnectedForBlog ( blog)
132+ } else {
133+ self ? . dismiss ( )
134+ }
135+ } ,
136+ failure: { [ weak self] error in
137+ self ? . stopLoading ( )
138+ let errorTitle = NSLocalizedString (
139+ " Error disconnecting Jetpack " ,
140+ comment: " Title of error dialog when disconnecting jetpack fails. "
141+ )
142+ let errorMessage = NSLocalizedString (
143+ " Please contact support for assistance. " ,
144+ comment: " Message displayed on an error alert to prompt the user to contact support "
145+ )
146+ WPError . showAlert ( withTitle: errorTitle, message: errorMessage, withSupportButton: true )
147+ DDLogError ( " Error disconnecting Jetpack: \( String ( describing: error) ) " )
148+ }
149+ )
128150 }
129151
130152 @objc func dismiss( ) {
0 commit comments