mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-23 15:50:26 +01:00
Tidies up Delegate and Coordinator code
This commit is contained in:
parent
cf0e3ba6a2
commit
0b4640db04
@ -807,24 +807,27 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectTodayFeed() {
|
func selectTodayFeed(completion: @escaping () -> () = {}) {
|
||||||
markExpanded(SmartFeedsController.shared)
|
markExpanded(SmartFeedsController.shared)
|
||||||
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.todayFeed) {
|
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.todayFeed) {
|
||||||
self.selectFeed(SmartFeedsController.shared.todayFeed, animations: [.navigation, .scroll])
|
self.selectFeed(SmartFeedsController.shared.todayFeed, animations: [.navigation, .scroll])
|
||||||
|
completion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectAllUnreadFeed() {
|
func selectAllUnreadFeed(completion: @escaping () -> () = {}) {
|
||||||
markExpanded(SmartFeedsController.shared)
|
markExpanded(SmartFeedsController.shared)
|
||||||
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) {
|
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.unreadFeed) {
|
||||||
self.selectFeed(SmartFeedsController.shared.unreadFeed, animations: [.navigation, .scroll])
|
self.selectFeed(SmartFeedsController.shared.unreadFeed, animations: [.navigation, .scroll])
|
||||||
|
completion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectStarredFeed() {
|
func selectStarredFeed(completion: @escaping () -> () = {}) {
|
||||||
markExpanded(SmartFeedsController.shared)
|
markExpanded(SmartFeedsController.shared)
|
||||||
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.starredFeed) {
|
self.ensureFeedIsAvailableToSelect(SmartFeedsController.shared.starredFeed) {
|
||||||
self.selectFeed(SmartFeedsController.shared.starredFeed, animations: [.navigation, .scroll])
|
self.selectFeed(SmartFeedsController.shared.starredFeed, animations: [.navigation, .scroll])
|
||||||
|
completion()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,6 +1280,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
func toggleSidebar() {
|
func toggleSidebar() {
|
||||||
rootSplitViewController.preferredDisplayMode = rootSplitViewController.displayMode == .allVisible ? .primaryHidden : .allVisible
|
rootSplitViewController.preferredDisplayMode = rootSplitViewController.displayMode == .allVisible ? .primaryHidden : .allVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func selectArticleInCurrentFeed(_ articleID: String) {
|
||||||
|
if let article = self.articles.first(where: { $0.articleID == articleID }) {
|
||||||
|
self.selectArticle(article)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: UISplitViewControllerDelegate
|
// MARK: UISplitViewControllerDelegate
|
||||||
@ -2291,10 +2300,4 @@ private extension SceneCoordinator {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectArticleInCurrentFeed(_ articleID: String) {
|
|
||||||
if let article = self.articles.first(where: { $0.articleID == articleID }) {
|
|
||||||
self.selectArticle(article)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,22 +105,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
if AccountManager.shared.isSuspended {
|
if AccountManager.shared.isSuspended {
|
||||||
AccountManager.shared.resumeAll()
|
AccountManager.shared.resumeAll()
|
||||||
}
|
}
|
||||||
let articles = try! AccountManager.shared.fetchArticles(.unread)
|
self.coordinator.selectAllUnreadFeed(completion: {
|
||||||
let article = articles.filter({ $0.articleID == id }).first
|
|
||||||
|
|
||||||
if article != nil {
|
|
||||||
self.coordinator.selectAllUnreadFeed()
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
self.coordinator.selectArticle(article!, animations: [.navigation, .scroll])
|
self.coordinator.selectArticleInCurrentFeed(id!)
|
||||||
})
|
})
|
||||||
return
|
})
|
||||||
} else {
|
|
||||||
self.coordinator.selectAllUnreadFeed()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.coordinator.selectAllUnreadFeed()
|
self.coordinator.selectAllUnreadFeed()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,22 +123,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
if AccountManager.shared.isSuspended {
|
if AccountManager.shared.isSuspended {
|
||||||
AccountManager.shared.resumeAll()
|
AccountManager.shared.resumeAll()
|
||||||
}
|
}
|
||||||
let articles = try! AccountManager.shared.fetchArticles(.today)
|
self.coordinator.selectTodayFeed(completion: {
|
||||||
let article = articles.filter({ $0.articleID == id }).first
|
|
||||||
|
|
||||||
if article != nil {
|
|
||||||
self.coordinator.selectTodayFeed()
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
self.coordinator.selectArticle(article!, animations: [.navigation, .scroll])
|
self.coordinator.selectArticleInCurrentFeed(id!)
|
||||||
})
|
})
|
||||||
return
|
})
|
||||||
} else {
|
|
||||||
self.coordinator.selectTodayFeed()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.coordinator.selectTodayFeed()
|
self.coordinator.selectTodayFeed()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,22 +141,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
if AccountManager.shared.isSuspended {
|
if AccountManager.shared.isSuspended {
|
||||||
AccountManager.shared.resumeAll()
|
AccountManager.shared.resumeAll()
|
||||||
}
|
}
|
||||||
let articles = try! AccountManager.shared.fetchArticles(.starred)
|
self.coordinator.selectStarredFeed(completion: {
|
||||||
let article = articles.filter({ $0.articleID == id }).first
|
|
||||||
|
|
||||||
if article != nil {
|
|
||||||
self.coordinator.selectStarredFeed()
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
|
||||||
self.coordinator.selectArticle(article!, animations: [.navigation, .scroll])
|
self.coordinator.selectArticleInCurrentFeed(id!)
|
||||||
})
|
})
|
||||||
return
|
})
|
||||||
} else {
|
|
||||||
self.coordinator.selectStarredFeed()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.coordinator.selectStarredFeed()
|
self.coordinator.selectStarredFeed()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user