Rebuild the backing stores to except spotlight search result restoration. Issue #1759
This commit is contained in:
parent
e47e2d4ea0
commit
76bad13ae1
@ -360,27 +360,27 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(_ activity: NSUserActivity) {
|
func handle(_ activity: NSUserActivity, initialLoad: Bool) {
|
||||||
selectFeed(nil) {
|
selectFeed(nil) {
|
||||||
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
|
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
|
||||||
switch activityType {
|
switch activityType {
|
||||||
case .restoration:
|
case .restoration:
|
||||||
break
|
break
|
||||||
case .selectFeed:
|
case .selectFeed:
|
||||||
self.handleSelectFeed(activity.userInfo)
|
self.handleSelectFeed(activity.userInfo, initialLoad: initialLoad)
|
||||||
case .nextUnread:
|
case .nextUnread:
|
||||||
self.selectFirstUnreadInAllUnread()
|
self.selectFirstUnreadInAllUnread()
|
||||||
case .readArticle:
|
case .readArticle:
|
||||||
self.handleReadArticle(activity.userInfo)
|
self.handleReadArticle(activity.userInfo, initialLoad: initialLoad)
|
||||||
case .addFeedIntent:
|
case .addFeedIntent:
|
||||||
self.showAdd(.feed)
|
self.showAdd(.feed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(_ response: UNNotificationResponse) {
|
func handle(_ response: UNNotificationResponse, initialLoad: Bool) {
|
||||||
let userInfo = response.notification.request.content.userInfo
|
let userInfo = response.notification.request.content.userInfo
|
||||||
handleReadArticle(userInfo)
|
handleReadArticle(userInfo, initialLoad: initialLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configurePanelMode(for size: CGSize) {
|
func configurePanelMode(for size: CGSize) {
|
||||||
@ -1920,7 +1920,7 @@ private extension SceneCoordinator {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleSelectFeed(_ userInfo: [AnyHashable : Any]?) {
|
func handleSelectFeed(_ userInfo: [AnyHashable : Any]?, initialLoad: Bool) {
|
||||||
guard let userInfo = userInfo,
|
guard let userInfo = userInfo,
|
||||||
let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : AnyHashable],
|
let feedIdentifierUserInfo = userInfo[UserInfoKey.feedIdentifier] as? [AnyHashable : AnyHashable],
|
||||||
let feedIdentifier = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
let feedIdentifier = FeedIdentifier(userInfo: feedIdentifierUserInfo) else {
|
||||||
@ -1930,11 +1930,20 @@ private extension SceneCoordinator {
|
|||||||
treeControllerDelegate.addFilterException(feedIdentifier)
|
treeControllerDelegate.addFilterException(feedIdentifier)
|
||||||
masterFeedViewController.restoreSelection = true
|
masterFeedViewController.restoreSelection = true
|
||||||
|
|
||||||
|
func rebuildIfNecessary() {
|
||||||
|
if !initialLoad && isReadFeedsFiltered {
|
||||||
|
rebuildBackingStores()
|
||||||
|
treeControllerDelegate.resetFilterExceptions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch feedIdentifier {
|
switch feedIdentifier {
|
||||||
|
|
||||||
case .smartFeed:
|
case .smartFeed:
|
||||||
guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return }
|
guard let smartFeed = SmartFeedsController.shared.find(by: feedIdentifier) else { return }
|
||||||
|
|
||||||
|
rebuildIfNecessary()
|
||||||
|
|
||||||
if let indexPath = indexPathFor(smartFeed) {
|
if let indexPath = indexPathFor(smartFeed) {
|
||||||
selectFeed(indexPath) {
|
selectFeed(indexPath) {
|
||||||
self.masterFeedViewController.focus()
|
self.masterFeedViewController.focus()
|
||||||
@ -1945,6 +1954,8 @@ private extension SceneCoordinator {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case .folder(let accountID, let folderName):
|
case .folder(let accountID, let folderName):
|
||||||
|
rebuildIfNecessary()
|
||||||
|
|
||||||
guard let accountNode = findAccountNode(accountID: accountID), let folderNode = findFolderNode(folderName: folderName, beginningAt: accountNode) else {
|
guard let accountNode = findAccountNode(accountID: accountID), let folderNode = findFolderNode(folderName: folderName, beginningAt: accountNode) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1955,22 +1966,29 @@ private extension SceneCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case .webFeed(let accountID, let webFeedID):
|
case .webFeed(let accountID, let webFeedID):
|
||||||
guard let accountNode = findAccountNode(accountID: accountID), let feedNode = findWebFeedNode(webFeedID: webFeedID, beginningAt: accountNode) else {
|
guard let accountNode = findAccountNode(accountID: accountID),
|
||||||
|
let account = accountNode.representedObject as? Account,
|
||||||
|
let webFeed = account.existingWebFeed(withWebFeedID: webFeedID) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let folder = feedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID {
|
|
||||||
treeControllerDelegate.addFilterException(folderFeedID)
|
for folder in account.sortedFolders ?? [Folder]() {
|
||||||
}
|
if folder.objectIsChild(webFeed), let folderFeedID = folder.feedID {
|
||||||
if let feed = feedNode.representedObject as? WebFeed {
|
treeControllerDelegate.addFilterException(folderFeedID)
|
||||||
discloseFeed(feed) {
|
break
|
||||||
self.masterFeedViewController.focus()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rebuildIfNecessary()
|
||||||
|
|
||||||
|
discloseFeed(webFeed) {
|
||||||
|
self.masterFeedViewController.focus()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleReadArticle(_ userInfo: [AnyHashable : Any]?) {
|
func handleReadArticle(_ userInfo: [AnyHashable : Any]?, initialLoad: Bool) {
|
||||||
guard let userInfo = userInfo else { return }
|
guard let userInfo = userInfo else { return }
|
||||||
|
|
||||||
guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any],
|
guard let articlePathUserInfo = userInfo[UserInfoKey.articlePath] as? [AnyHashable : Any],
|
||||||
@ -1989,15 +2007,24 @@ private extension SceneCoordinator {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let webFeedNode = findWebFeedNode(webFeedID: webFeedID, beginningAt: accountNode),
|
guard let webFeed = account.existingWebFeed(withWebFeedID: webFeedID),
|
||||||
let webFeed = webFeedNode.representedObject as? WebFeed,
|
|
||||||
let webFeedFeedID = webFeed.feedID else {
|
let webFeedFeedID = webFeed.feedID else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
treeControllerDelegate.addFilterException(webFeedFeedID)
|
treeControllerDelegate.addFilterException(webFeedFeedID)
|
||||||
addParentFolderToFilterExceptions(webFeedNode)
|
for folder in account.sortedFolders ?? [Folder]() {
|
||||||
|
if folder.objectIsChild(webFeed), let folderFeedID = folder.feedID {
|
||||||
|
treeControllerDelegate.addFilterException(folderFeedID)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !initialLoad && isReadFeedsFiltered {
|
||||||
|
rebuildBackingStores()
|
||||||
|
treeControllerDelegate.resetFilterExceptions()
|
||||||
|
}
|
||||||
|
|
||||||
discloseFeed(webFeed) {
|
discloseFeed(webFeed) {
|
||||||
self.selectArticleInCurrentFeed(articleID)
|
self.selectArticleInCurrentFeed(articleID)
|
||||||
}
|
}
|
||||||
@ -2044,7 +2071,9 @@ private extension SceneCoordinator {
|
|||||||
let found = selectFeedAndArticle(feedNode: webFeedNode, articleID: articleID)
|
let found = selectFeedAndArticle(feedNode: webFeedNode, articleID: articleID)
|
||||||
if found {
|
if found {
|
||||||
treeControllerDelegate.addFilterException(feedIdentifier)
|
treeControllerDelegate.addFilterException(feedIdentifier)
|
||||||
addParentFolderToFilterExceptions(webFeedNode)
|
if let folder = webFeedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID {
|
||||||
|
treeControllerDelegate.addFilterException(folderFeedID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return found
|
return found
|
||||||
|
|
||||||
@ -2095,10 +2124,4 @@ private extension SceneCoordinator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addParentFolderToFilterExceptions(_ feedNode: Node) {
|
|
||||||
if let folder = feedNode.parent?.representedObject as? Folder, let folderFeedID = folder.feedID {
|
|
||||||
treeControllerDelegate.addFilterException(folderFeedID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
|
|
||||||
if let notificationResponse = connectionOptions.notificationResponse {
|
if let notificationResponse = connectionOptions.notificationResponse {
|
||||||
window!.makeKeyAndVisible()
|
window!.makeKeyAndVisible()
|
||||||
coordinator.handle(notificationResponse)
|
coordinator.handle(notificationResponse, initialLoad: true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if let userActivity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
|
if let userActivity = connectionOptions.userActivities.first ?? session.stateRestorationActivity {
|
||||||
coordinator.handle(userActivity)
|
coordinator.handle(userActivity, initialLoad: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
window!.makeKeyAndVisible()
|
window!.makeKeyAndVisible()
|
||||||
@ -52,7 +52,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
|
|
||||||
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
||||||
appDelegate.resumeDatabaseProcessingIfNecessary()
|
appDelegate.resumeDatabaseProcessingIfNecessary()
|
||||||
coordinator.handle(userActivity)
|
coordinator.handle(userActivity, initialLoad: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||||
@ -74,7 +74,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||||||
|
|
||||||
func handle(_ response: UNNotificationResponse) {
|
func handle(_ response: UNNotificationResponse) {
|
||||||
appDelegate.resumeDatabaseProcessingIfNecessary()
|
appDelegate.resumeDatabaseProcessingIfNecessary()
|
||||||
coordinator.handle(response)
|
coordinator.handle(response, initialLoad: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func suspend() {
|
func suspend() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user