Refactor SmartFeedController to find SmartFeeds by FeedIdentifier instead of the string identifier.
This commit is contained in:
parent
01f86d8c1b
commit
6d18cfec7c
@ -24,8 +24,10 @@ final class SmartFeedsController: DisplayNameProvider {
|
|||||||
self.smartFeeds = [todayFeed, unreadFeed, starredFeed]
|
self.smartFeeds = [todayFeed, unreadFeed, starredFeed]
|
||||||
}
|
}
|
||||||
|
|
||||||
func find(by identifier: String) -> PseudoFeed? {
|
func find(by identifier: FeedIdentifier) -> PseudoFeed? {
|
||||||
switch identifier {
|
switch identifier {
|
||||||
|
case .smartFeed(let stringIdentifer):
|
||||||
|
switch stringIdentifer {
|
||||||
case String(describing: TodayFeedDelegate.self):
|
case String(describing: TodayFeedDelegate.self):
|
||||||
return todayFeed
|
return todayFeed
|
||||||
case String(describing: UnreadFeed.self):
|
case String(describing: UnreadFeed.self):
|
||||||
@ -35,6 +37,9 @@ final class SmartFeedsController: DisplayNameProvider {
|
|||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1684,14 +1684,14 @@ private extension SceneCoordinator {
|
|||||||
func handleSelectFeed(_ userInfo: [AnyHashable : Any]?) {
|
func handleSelectFeed(_ userInfo: [AnyHashable : Any]?) {
|
||||||
guard let userInfo = userInfo,
|
guard let userInfo = userInfo,
|
||||||
let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : Any],
|
let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : Any],
|
||||||
let articleFetcherType = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
let feedIdentifier = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch articleFetcherType {
|
switch feedIdentifier {
|
||||||
|
|
||||||
case .smartFeed(let identifier):
|
case .smartFeed:
|
||||||
guard let smartFeed = SmartFeedsController.shared.find(by: identifier) else { return }
|
guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return }
|
||||||
if let indexPath = indexPathFor(smartFeed) {
|
if let indexPath = indexPathFor(smartFeed) {
|
||||||
selectFeed(indexPath, animated: false)
|
selectFeed(indexPath, animated: false)
|
||||||
}
|
}
|
||||||
@ -1744,14 +1744,14 @@ private extension SceneCoordinator {
|
|||||||
|
|
||||||
func restoreFeed(_ userInfo: [AnyHashable : Any], accountID: String, webFeedID: String, articleID: String) -> Bool {
|
func restoreFeed(_ userInfo: [AnyHashable : Any], accountID: String, webFeedID: String, articleID: String) -> Bool {
|
||||||
guard let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : Any],
|
guard let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : Any],
|
||||||
let articleFetcherType = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
let feedIdentifier = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
switch articleFetcherType {
|
switch feedIdentifier {
|
||||||
|
|
||||||
case .smartFeed(let identifier):
|
case .smartFeed:
|
||||||
guard let smartFeed = SmartFeedsController.shared.find(by: identifier) else { return false }
|
guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return false }
|
||||||
if smartFeed.fetchArticles().contains(accountID: accountID, articleID: articleID) {
|
if smartFeed.fetchArticles().contains(accountID: accountID, articleID: articleID) {
|
||||||
if let indexPath = indexPathFor(smartFeed) {
|
if let indexPath = indexPathFor(smartFeed) {
|
||||||
selectFeed(indexPath, animated: false) {
|
selectFeed(indexPath, animated: false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user