mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 00:31:14 +00:00
Put a guard’s return statement on its own line. It’s quicker for me to parse and easier to set a breakpoint. (Yes, I know that we can set a breakpoint for an inline return.)
This commit is contained in:
1 parent
e2eca11b6c
commit
3036fb74bd
2 files changed
+72
-24
No files matched your search
@@ -39,7 +39,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
// If the first responder is the WKWebView (PreloadedWebView) we don't want to supply any keyboard
|
||||
// commands that the system is looking for by going up the responder chain. They will interfere with
|
||||
// the WKWebViews built in hardware keyboard shortcuts, specifically the up and down arrow keys.
|
||||
guard let current = UIResponder.currentFirstResponder, !(current is PreloadedWebView) else { return nil }
|
||||
guard let current = UIResponder.currentFirstResponder, !(current is PreloadedWebView) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return keyboardManager.keyCommands
|
||||
}
|
||||
@@ -225,7 +227,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
dataSource = UICollectionViewDiffableDataSource<String, FeedNode>(
|
||||
collectionView: collectionView
|
||||
) { [weak self] collectionView, indexPath, feedNode -> UICollectionViewCell? in
|
||||
guard let self else { return nil }
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if feedNode.node.representedObject is Folder {
|
||||
let cell = collectionView.dequeueReusableCell(
|
||||
@@ -246,7 +250,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
}
|
||||
|
||||
dataSource.supplementaryViewProvider = { [weak self] collectionView, kind, indexPath in
|
||||
guard let self else { return nil }
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
guard kind == UICollectionView.elementKindSectionHeader else {
|
||||
return UICollectionReusableView()
|
||||
}
|
||||
@@ -549,7 +555,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
}
|
||||
|
||||
func configure(_ cell: MainFeedCollectionViewCell, indexPath: IndexPath) {
|
||||
guard let node = coordinator.nodeFor(indexPath) else { return }
|
||||
guard let node = coordinator.nodeFor(indexPath) else {
|
||||
return
|
||||
}
|
||||
var indentationLevel = 0
|
||||
if node.parent?.representedObject is Folder {
|
||||
indentationLevel = 1
|
||||
@@ -565,7 +573,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
|
||||
/// Configure folders
|
||||
func configure(_ cell: MainFeedCollectionViewFolderCell, indexPath: IndexPath) {
|
||||
guard let node = coordinator.nodeFor(indexPath) else { return }
|
||||
guard let node = coordinator.nodeFor(indexPath) else {
|
||||
return
|
||||
}
|
||||
|
||||
if let folder = node.representedObject as? Folder {
|
||||
cell.folderTitle.text = folder.nameForDisplay
|
||||
@@ -590,7 +600,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
}
|
||||
|
||||
private func reloadAllVisibleCells(completion: (() -> Void)? = nil) {
|
||||
guard let indexPaths = collectionView.indexPathsForSelectedItems else { return }
|
||||
guard let indexPaths = collectionView.indexPathsForSelectedItems else {
|
||||
return
|
||||
}
|
||||
collectionView.reloadItems(at: indexPaths)
|
||||
restoreSelectionIfNecessary(adjustScroll: false)
|
||||
}
|
||||
@@ -628,7 +640,9 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
|
||||
let node: Node? = coordinator.rootNode.descendantNodeRepresentingObject(unreadCountProvider as AnyObject)
|
||||
|
||||
guard let unreadCountNode = node, let indexPath = coordinator.indexPathFor(unreadCountNode) else { return }
|
||||
guard let unreadCountNode = node, let indexPath = coordinator.indexPathFor(unreadCountNode) else {
|
||||
return
|
||||
}
|
||||
|
||||
if let cell = collectionView.cellForItem(at: indexPath) as? MainFeedCollectionViewCell {
|
||||
cell.unreadCount = unreadCountProvider.unreadCount
|
||||
@@ -813,7 +827,9 @@ extension MainFeedCollectionViewController {
|
||||
func makeFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] _ in
|
||||
|
||||
guard let self = self else { return nil }
|
||||
guard let self = self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
var menuElements = [UIMenuElement]()
|
||||
|
||||
@@ -856,7 +872,9 @@ extension MainFeedCollectionViewController {
|
||||
func makeFolderContextMenu(indexPath: IndexPath) -> UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [weak self] _ in
|
||||
|
||||
guard let self = self else { return nil }
|
||||
guard let self = self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
var menuElements = [UIMenuElement]()
|
||||
|
||||
@@ -1089,7 +1107,9 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
func rename(indexPath: IndexPath) {
|
||||
guard let sidebarItem = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem else { return }
|
||||
guard let sidebarItem = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem else {
|
||||
return
|
||||
}
|
||||
|
||||
let formatString = NSLocalizedString("Rename “%@”", comment: "Rename feed")
|
||||
let title = NSString.localizedStringWithFormat(formatString as NSString, sidebarItem.nameForDisplay) as String
|
||||
@@ -1144,7 +1164,9 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
func delete(indexPath: IndexPath) {
|
||||
guard let sidebarItem = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem else { return }
|
||||
guard let sidebarItem = coordinator.nodeFor(indexPath)?.representedObject as? SidebarItem else {
|
||||
return
|
||||
}
|
||||
|
||||
let title: String
|
||||
let message: String
|
||||
|
||||
+39
-13
@@ -275,7 +275,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
}
|
||||
|
||||
private var currentArticleRow: Int? {
|
||||
guard let article = currentArticle else { return nil }
|
||||
guard let article = currentArticle else {
|
||||
return nil
|
||||
}
|
||||
return articles.firstIndex(of: article)
|
||||
}
|
||||
|
||||
@@ -405,7 +407,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
|
||||
func handle(_ activity: NSUserActivity) {
|
||||
selectFeed(indexPath: nil) {
|
||||
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
|
||||
guard let activityType = ActivityType(rawValue: activity.activityType) else {
|
||||
return
|
||||
}
|
||||
switch activityType {
|
||||
case .restoration:
|
||||
break
|
||||
@@ -771,7 +775,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
func cappedIndexPath(_ indexPath: IndexPath) -> IndexPath {
|
||||
let snapshot = mainFeedCollectionViewController.dataSource.snapshot()
|
||||
let numberOfSections = snapshot.numberOfSections
|
||||
guard numberOfSections > 0 else { return indexPath }
|
||||
guard numberOfSections > 0 else {
|
||||
return indexPath
|
||||
}
|
||||
|
||||
guard indexPath.section < numberOfSections else {
|
||||
let lastSection = numberOfSections - 1
|
||||
@@ -835,7 +841,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
/// This is a special function that expects the caller to change the disclosure arrow state outside this function.
|
||||
/// Failure to do so will get the Sidebar into an invalid state.
|
||||
func expand(_ node: Node) {
|
||||
guard let containerID = (node.representedObject as? ContainerIdentifiable)?.containerID else { return }
|
||||
guard let containerID = (node.representedObject as? ContainerIdentifiable)?.containerID else {
|
||||
return
|
||||
}
|
||||
lastExpandedContainers.insert(containerID)
|
||||
expand(containerID)
|
||||
}
|
||||
@@ -863,7 +871,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
/// This is a special function that expects the caller to change the disclosure arrow state outside this function.
|
||||
/// Failure to do so will get the Sidebar into an invalid state.
|
||||
func collapse(_ node: Node) {
|
||||
guard let containerID = (node.representedObject as? ContainerIdentifiable)?.containerID else { return }
|
||||
guard let containerID = (node.representedObject as? ContainerIdentifiable)?.containerID else {
|
||||
return
|
||||
}
|
||||
lastExpandedContainers.remove(containerID)
|
||||
collapse(containerID)
|
||||
}
|
||||
@@ -975,7 +985,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
}
|
||||
|
||||
func selectArticle(_ article: Article?, animations: Animations = [], isShowingExtractedArticle: Bool? = nil, articleWindowScrollY: Int? = nil) {
|
||||
guard article != currentArticle else { return }
|
||||
guard article != currentArticle else {
|
||||
return
|
||||
}
|
||||
|
||||
currentArticle = article
|
||||
activityManager.reading(feed: timelineFeed, article: article)
|
||||
@@ -1030,7 +1042,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
|
||||
func searchArticles(_ searchString: String, _ searchScope: SearchScope) {
|
||||
|
||||
guard isSearching else { return }
|
||||
guard isSearching else {
|
||||
return
|
||||
}
|
||||
|
||||
if searchString.count < 3 {
|
||||
setTimelineFeed(nil, animated: true)
|
||||
@@ -1212,7 +1226,9 @@ struct FeedNode: Hashable, Sendable {
|
||||
}
|
||||
|
||||
func toggleRead(_ article: Article) {
|
||||
guard !article.status.read || article.isAvailableToMarkUnread else { return }
|
||||
guard !article.status.read || article.isAvailableToMarkUnread else {
|
||||
return
|
||||
}
|
||||
markArticlesWithUndo([article], statusKey: .read, flag: !article.status.read)
|
||||
}
|
||||
|
||||
@@ -1378,12 +1394,16 @@ struct FeedNode: Hashable, Sendable {
|
||||
}
|
||||
|
||||
func showBrowserForArticle(_ article: Article) {
|
||||
guard let url = article.preferredURL else { return }
|
||||
guard let url = article.preferredURL else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
}
|
||||
|
||||
func showBrowserForCurrentArticle() {
|
||||
guard let url = currentArticle?.preferredURL else { return }
|
||||
guard let url = currentArticle?.preferredURL else {
|
||||
return
|
||||
}
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
}
|
||||
|
||||
@@ -1434,12 +1454,16 @@ struct FeedNode: Hashable, Sendable {
|
||||
/// `SFSafariViewController` or `SettingsViewController`,
|
||||
/// otherwise, this function does nothing.
|
||||
func dismissIfLaunchingFromExternalAction() {
|
||||
guard let presentedController = mainFeedCollectionViewController.presentedViewController else { return }
|
||||
guard let presentedController = mainFeedCollectionViewController.presentedViewController else {
|
||||
return
|
||||
}
|
||||
|
||||
if presentedController.isKind(of: SFSafariViewController.self) {
|
||||
presentedController.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
guard let settings = presentedController.children.first as? SettingsViewController else { return }
|
||||
guard let settings = presentedController.children.first as? SettingsViewController else {
|
||||
return
|
||||
}
|
||||
settings.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@@ -2211,7 +2235,9 @@ private extension SceneCoordinator {
|
||||
}
|
||||
|
||||
func handleReadArticle(_ userInfo: [AnyHashable: Any]?) {
|
||||
guard let userInfo = userInfo else { return }
|
||||
guard let userInfo = userInfo else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable: Any],
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
|
||||
Reference in new issue
Block a user