Exclude currently selected article from feed filter. Issue #1841
This commit is contained in:
parent
5eed42721e
commit
80858adced
@ -104,6 +104,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
var undoableCommands = [UndoableCommand]()
|
var undoableCommands = [UndoableCommand]()
|
||||||
private var fetchSerialNumber = 0
|
private var fetchSerialNumber = 0
|
||||||
private let fetchRequestQueue = FetchRequestQueue()
|
private let fetchRequestQueue = FetchRequestQueue()
|
||||||
|
private var exceptionArticleFetcher: ArticleFetcher?
|
||||||
private var articleRowMap = [String: Int]() // articleID: rowIndex
|
private var articleRowMap = [String: Int]() // articleID: rowIndex
|
||||||
private var cellAppearance: TimelineCellAppearance!
|
private var cellAppearance: TimelineCellAppearance!
|
||||||
private var cellAppearanceWithIcon: TimelineCellAppearance!
|
private var cellAppearanceWithIcon: TimelineCellAppearance!
|
||||||
@ -223,6 +224,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
|
|
||||||
func toggleReadFilter() {
|
func toggleReadFilter() {
|
||||||
guard let filterType = articleReadFilterType else { return }
|
guard let filterType = articleReadFilterType else { return }
|
||||||
|
|
||||||
switch filterType {
|
switch filterType {
|
||||||
case .alwaysRead:
|
case .alwaysRead:
|
||||||
break
|
break
|
||||||
@ -231,7 +233,14 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
case .none:
|
case .none:
|
||||||
articleReadFilterType = ReadFilterType.read
|
articleReadFilterType = ReadFilterType.read
|
||||||
}
|
}
|
||||||
fetchAndReplaceArticlesAsync()
|
|
||||||
|
if let article = oneSelectedArticle, let account = article.account {
|
||||||
|
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: article.articleID)
|
||||||
|
}
|
||||||
|
|
||||||
|
performBlockAndRestoreSelection {
|
||||||
|
fetchAndReplaceArticlesSync()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
@ -420,6 +429,15 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
|
|
||||||
func goToDeepLink(for userInfo: [AnyHashable : Any]) {
|
func goToDeepLink(for userInfo: [AnyHashable : Any]) {
|
||||||
guard let articleID = userInfo[ArticlePathKey.articleID] as? String else { return }
|
guard let articleID = userInfo[ArticlePathKey.articleID] as? String else { return }
|
||||||
|
|
||||||
|
if isReadFiltered ?? false {
|
||||||
|
if let accountName = userInfo[ArticlePathKey.accountName] as? String,
|
||||||
|
let account = AccountManager.shared.findActiveAccount(forDisplayName: accountName) {
|
||||||
|
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: articleID)
|
||||||
|
fetchAndReplaceArticlesSync()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
guard let ix = articles.firstIndex(where: { $0.articleID == articleID }) else { return }
|
guard let ix = articles.firstIndex(where: { $0.articleID == articleID }) else { return }
|
||||||
|
|
||||||
NSCursor.setHiddenUntilMouseMoves(true)
|
NSCursor.setHiddenUntilMouseMoves(true)
|
||||||
@ -991,10 +1009,16 @@ private extension TimelineViewController {
|
|||||||
// so that the entire display refreshes at once.
|
// so that the entire display refreshes at once.
|
||||||
// It’s a better user experience this way.
|
// It’s a better user experience this way.
|
||||||
cancelPendingAsyncFetches()
|
cancelPendingAsyncFetches()
|
||||||
guard let representedObjects = representedObjects else {
|
guard var representedObjects = representedObjects else {
|
||||||
emptyTheTimeline()
|
emptyTheTimeline()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if exceptionArticleFetcher != nil {
|
||||||
|
representedObjects.append(exceptionArticleFetcher as AnyObject)
|
||||||
|
exceptionArticleFetcher = nil
|
||||||
|
}
|
||||||
|
|
||||||
let fetchedArticles = fetchUnsortedArticlesSync(for: representedObjects)
|
let fetchedArticles = fetchUnsortedArticlesSync(for: representedObjects)
|
||||||
replaceArticles(with: fetchedArticles)
|
replaceArticles(with: fetchedArticles)
|
||||||
}
|
}
|
||||||
@ -1003,10 +1027,16 @@ private extension TimelineViewController {
|
|||||||
// To be called when we need to do an entire fetch, but an async delay is okay.
|
// To be called when we need to do an entire fetch, but an async delay is okay.
|
||||||
// Example: we have the Today feed selected, and the calendar day just changed.
|
// Example: we have the Today feed selected, and the calendar day just changed.
|
||||||
cancelPendingAsyncFetches()
|
cancelPendingAsyncFetches()
|
||||||
guard let representedObjects = representedObjects else {
|
guard var representedObjects = representedObjects else {
|
||||||
emptyTheTimeline()
|
emptyTheTimeline()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if exceptionArticleFetcher != nil {
|
||||||
|
representedObjects.append(exceptionArticleFetcher as AnyObject)
|
||||||
|
exceptionArticleFetcher = nil
|
||||||
|
}
|
||||||
|
|
||||||
fetchUnsortedArticlesAsync(for: representedObjects) { [weak self] (articles) in
|
fetchUnsortedArticlesAsync(for: representedObjects) { [weak self] (articles) in
|
||||||
self?.replaceArticles(with: articles)
|
self?.replaceArticles(with: articles)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user