Remove deferrer feed and article select hack

This commit is contained in:
Maurice Parker 2021-10-21 13:08:18 -05:00
parent f93cedfca0
commit 5f4409ca1f
1 changed files with 8 additions and 33 deletions

View File

@ -177,21 +177,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
private var exceptionArticleFetcher: ArticleFetcher? private var exceptionArticleFetcher: ArticleFetcher?
private(set) var timelineFeed: Feed? private(set) var timelineFeed: Feed?
// We have to defer the selecting of the feed and article due to a behavior (bug?) in iOS 15.
// iOS 15 will crash if you are in landscape on an iPad and are restoring article state. We
// have no idea why this is, but it happens when you do a select on a UITableView right before
// doing a diffable datasource apply.
//
// Steps to recreate:
//
// * Try to relaunch the app in the sim.
// * Press the Stop button in Xcode
// * Wait for all the app suspension activities to complete (widget data, etc)
// * Once the article has loaded, navigate to the iPad home screen
// * While in landscape, select a feed and then select an article
// * Install a fresh build of NNW to an iPad simulator (11 or 12.9' will do) running iPadOS 15
private var deferredFeedAndArticleSelect: (feedIdentifier: FeedIdentifier, articleID: String, isShowingExtractedArticle: Bool, articleWindowScrollY: Int)?
var timelineMiddleIndexPath: IndexPath? var timelineMiddleIndexPath: IndexPath?
private(set) var showFeedNames = ShowFeedName.none private(set) var showFeedNames = ShowFeedName.none
@ -467,16 +452,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
return return
} }
rebuildBackingStores(initialLoad: true, completion: { if isReadFeedsFiltered {
if let (feedIdentifier, articleID, isShowingExtractedArticle, articleWindowScrollY) = self.deferredFeedAndArticleSelect, rebuildBackingStores()
let feedNode = self.nodeFor(feedID: feedIdentifier),
let feedIndexPath = self.indexPathFor(feedNode) {
self.selectFeed(indexPath: feedIndexPath) {
self.selectArticleInCurrentFeed(articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)
} }
} }
})
}
@objc func unreadCountDidChange(_ note: Notification) { @objc func unreadCountDidChange(_ note: Notification) {
// We will handle the filtering of unread feeds in unreadCountDidInitialize after they have all be calculated // We will handle the filtering of unread feeds in unreadCountDidInitialize after they have all be calculated
@ -2324,14 +2303,14 @@ private extension SceneCoordinator {
return false return false
case .smartFeed, .folder: case .smartFeed, .folder:
let found = deferSelectFeedAndArticle(feedIdentifier: feedIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY) let found = selectFeedAndArticle(feedIdentifier: feedIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)
if found { if found {
treeControllerDelegate.addFilterException(feedIdentifier) treeControllerDelegate.addFilterException(feedIdentifier)
} }
return found return found
case .webFeed: case .webFeed:
let found = deferSelectFeedAndArticle(feedIdentifier: feedIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY) let found = selectFeedAndArticle(feedIdentifier: feedIdentifier, articleID: articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)
if found { if found {
treeControllerDelegate.addFilterException(feedIdentifier) treeControllerDelegate.addFilterException(feedIdentifier)
if let webFeedNode = nodeFor(feedID: feedIdentifier), let folder = webFeedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID { if let webFeedNode = nodeFor(feedID: feedIdentifier), let folder = webFeedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID {
@ -2370,16 +2349,12 @@ private extension SceneCoordinator {
return nil return nil
} }
func deferSelectFeedAndArticle(feedIdentifier: FeedIdentifier, articleID: String, isShowingExtractedArticle: Bool, articleWindowScrollY: Int) -> Bool { func selectFeedAndArticle(feedIdentifier: FeedIdentifier, articleID: String, isShowingExtractedArticle: Bool, articleWindowScrollY: Int) -> Bool {
guard let feedNode = nodeFor(feedID: feedIdentifier), let feedIndexPath = indexPathFor(feedNode) else { return false } guard let feedNode = nodeFor(feedID: feedIdentifier), let feedIndexPath = indexPathFor(feedNode) else { return false }
if AccountManager.shared.isUnreadCountsInitialized {
selectFeed(indexPath: feedIndexPath) { selectFeed(indexPath: feedIndexPath) {
self.selectArticleInCurrentFeed(articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY) self.selectArticleInCurrentFeed(articleID, isShowingExtractedArticle: isShowingExtractedArticle, articleWindowScrollY: articleWindowScrollY)
} }
} else {
deferredFeedAndArticleSelect = (feedIdentifier, articleID, isShowingExtractedArticle, articleWindowScrollY)
}
return true return true
} }