Skip to content

Commit a34822c

Browse files
committed
Reformat three files per swift-format
Mechanical swift-format pass over the files that the later Media Library upload and external-source changes touch, isolated here so the feature commits carry no formatting noise. No behavior change.
1 parent cbfa85e commit a34822c

3 files changed

Lines changed: 120 additions & 61 deletions

File tree

WordPress/Classes/Services/SiteManagementService.swift

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ open class SiteManagementService: NSObject {
3030
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
3131
return
3232
}
33-
remote.deleteSite(blog.dotComID!,
33+
remote.deleteSite(
34+
blog.dotComID!,
3435
success: {
3536
let blogService = BlogService(coreDataStack: self.coreDataStack)
3637
blogService.remove(blog)
@@ -41,7 +42,8 @@ open class SiteManagementService: NSObject {
4142
},
4243
failure: { error in
4344
failure?(error)
44-
})
45+
}
46+
)
4547
}
4648

4749
/// Triggers content export of the specified WordPress.com site.
@@ -57,13 +59,15 @@ open class SiteManagementService: NSObject {
5759
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
5860
return
5961
}
60-
remote.exportContent(blog.dotComID!,
62+
remote.exportContent(
63+
blog.dotComID!,
6164
success: {
6265
success?()
6366
},
6467
failure: { error in
6568
failure?(error)
66-
})
69+
}
70+
)
6771
}
6872

6973
/// Gets the list of active purchases of the specified WordPress.com site.
@@ -73,17 +77,23 @@ open class SiteManagementService: NSObject {
7377
/// - success: Optional success block with array of purchases (if any)
7478
/// - failure: Optional failure block with NSError
7579
///
76-
@objc open func getActivePurchasesForBlog(_ blog: Blog, success: (([SitePurchase]) -> Void)?, failure: ((NSError) -> Void)?) {
80+
@objc open func getActivePurchasesForBlog(
81+
_ blog: Blog,
82+
success: (([SitePurchase]) -> Void)?,
83+
failure: ((NSError) -> Void)?
84+
) {
7785
guard let remote = siteManagementServiceRemoteForBlog(blog) else {
7886
return
7987
}
80-
remote.getActivePurchases(blog.dotComID!,
88+
remote.getActivePurchases(
89+
blog.dotComID!,
8190
success: { purchases in
8291
success?(purchases)
8392
},
8493
failure: { error in
8594
failure?(error)
86-
})
95+
}
96+
)
8797
}
8898

8999
/// Creates a remote service for site management

WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackConnectionViewController.swift

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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() {

WordPress/Classes/ViewRelated/Media/External/ExternalMediaPickerViewController.swift

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ import WordPressShared
44

55
protocol ExternalMediaPickerViewDelegate: AnyObject {
66
/// If the user cancels the flow, the selection is empty.
7-
func externalMediaPickerViewController(_ viewController: ExternalMediaPickerViewController, didFinishWithSelection selection: [ExternalMediaAsset])
7+
func externalMediaPickerViewController(
8+
_ viewController: ExternalMediaPickerViewController,
9+
didFinishWithSelection selection: [ExternalMediaAsset]
10+
)
811
}
912

10-
final class ExternalMediaPickerViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UISearchResultsUpdating, MediaPreviewControllerDataSource {
13+
final class ExternalMediaPickerViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate,
14+
UISearchResultsUpdating, MediaPreviewControllerDataSource
15+
{
1116
private lazy var collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
1217
private lazy var flowLayout = UICollectionViewFlowLayout()
1318
private var collectionViewDataSource: UICollectionViewDiffableDataSource<Int, String>!
1419
private let searchController = UISearchController()
1520
private let activityIndicator = UIActivityIndicatorView()
1621
private let toolbarItemTitle = ExternalMediaSelectionTitleView()
17-
private lazy var buttonDone = UIBarButtonItem(title: Strings.add, style: .done, target: self, action: #selector(buttonDoneTapped))
22+
private lazy var buttonDone = UIBarButtonItem(
23+
title: Strings.add,
24+
style: .done,
25+
target: self,
26+
action: #selector(buttonDoneTapped)
27+
)
1828

1929
private let dataSource: ExternalMediaDataSource
2030
private var assets: [String: ExternalMediaAsset] = [:]
@@ -32,9 +42,11 @@ final class ExternalMediaPickerViewController: UIViewController, UICollectionVie
3242

3343
private static let cellReuseID = "ExternalMediaPickerCollectionCell"
3444

35-
init(dataSource: ExternalMediaDataSource,
36-
source: MediaSource,
37-
allowsMultipleSelection: Bool = false) {
45+
init(
46+
dataSource: ExternalMediaDataSource,
47+
source: MediaSource,
48+
allowsMultipleSelection: Bool = false
49+
) {
3850
self.dataSource = dataSource
3951
self.source = source
4052
self.allowsMultipleSelection = allowsMultipleSelection
@@ -133,9 +145,12 @@ final class ExternalMediaPickerViewController: UIViewController, UICollectionVie
133145
}
134146

135147
private func configureNavigationItems() {
136-
let buttonCancel = UIBarButtonItem(systemItem: .cancel, primaryAction: UIAction { [weak self] _ in
137-
self?.buttonCancelTapped()
138-
})
148+
let buttonCancel = UIBarButtonItem(
149+
systemItem: .cancel,
150+
primaryAction: UIAction { [weak self] _ in
151+
self?.buttonCancelTapped()
152+
}
153+
)
139154
navigationItem.leftBarButtonItem = buttonCancel
140155
if allowsMultipleSelection {
141156
navigationItem.rightBarButtonItems = [buttonDone]
@@ -152,7 +167,11 @@ final class ExternalMediaPickerViewController: UIViewController, UICollectionVie
152167
toolbarItems.append(UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil))
153168
self.toolbarItems = toolbarItems
154169

155-
toolbarItemTitle.buttonViewSelected.addTarget(self, action: #selector(buttonPreviewSelectionTapped), for: .touchUpInside)
170+
toolbarItemTitle.buttonViewSelected.addTarget(
171+
self,
172+
action: #selector(buttonPreviewSelectionTapped),
173+
for: .touchUpInside
174+
)
156175
}
157176

158177
private func didUpdateAssets() {
@@ -234,8 +253,11 @@ final class ExternalMediaPickerViewController: UIViewController, UICollectionVie
234253
dataSource.assets.count
235254
}
236255

237-
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
238-
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: Self.cellReuseID, for: indexPath) as! ExternalMediaPickerCollectionCell
256+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
257+
{
258+
let cell =
259+
collectionView.dequeueReusableCell(withReuseIdentifier: Self.cellReuseID, for: indexPath)
260+
as! ExternalMediaPickerCollectionCell
239261
let item = dataSource.assets[indexPath.item]
240262
cell.configure(imageURL: item.thumbnailURL, size: ImageSize(scaling: flowLayout.itemSize, in: self.view))
241263
return cell
@@ -277,13 +299,18 @@ final class ExternalMediaPickerViewController: UIViewController, UICollectionVie
277299

278300
func previewController(_ controller: MediaPreviewController, previewItemAt index: Int) -> MediaPreviewItem? {
279301
guard let id = selection.object(at: index) as? String,
280-
let asset = assets[id] else {
302+
let asset = assets[id]
303+
else {
281304
return nil
282305
}
283306
return MediaPreviewItem(url: asset.largeURL)
284307
}
285308
}
286309

287310
private enum Strings {
288-
static let add = NSLocalizedString("externalMediaPicker.add", value: "Add", comment: "Title for confirmation navigation bar button item")
311+
static let add = NSLocalizedString(
312+
"externalMediaPicker.add",
313+
value: "Add",
314+
comment: "Title for confirmation navigation bar button item"
315+
)
289316
}

0 commit comments

Comments
 (0)