mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 03:08:43 +00:00
Move ArticleSpecifier to shared directory.
This commit is contained in:
1 parent
6bd59cb5de
commit
2c2cee645d
3 files changed
+24
-6
No files matched your search
@@ -430,6 +430,7 @@
|
||||
84D35E0C2DB9F32D004AA60E /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
ArticleSpecifier.swift,
|
||||
Extensions/IconImage.swift,
|
||||
"Extensions/Node-Extensions.swift",
|
||||
ShareExtension/ExtensionContainers.swift,
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Articles
|
||||
|
||||
/// Use this to refer to an Article when you can look it up.
|
||||
///
|
||||
@@ -19,7 +20,7 @@ struct ArticleSpecifier: Hashable, Sendable {
|
||||
static let articleID = "articleID"
|
||||
}
|
||||
|
||||
/// Plist-compatible dictionary, able to saved to disk or in UserDefaults.
|
||||
/// Plist-compatible dictionary, meant to be saved to disk or in UserDefaults.
|
||||
var dictionary: [String: String] {
|
||||
[Key.accountID: accountID, Key.articleID: articleID]
|
||||
}
|
||||
@@ -409,7 +409,20 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
let indexPath = indexPathFor(feedNode) else {
|
||||
return
|
||||
}
|
||||
selectFeed(indexPath: indexPath, animations: [])
|
||||
selectFeed(indexPath: indexPath, animations: []) {
|
||||
// Restore selectedArticle from UserDefaults
|
||||
if let articleSpecifier = AppDefaults.shared.selectedArticle {
|
||||
self.restoreSelectedArticle(articleSpecifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func restoreSelectedArticle(_ articleSpecifier: ArticleSpecifier) {
|
||||
// Find the article in the current timeline
|
||||
guard let article = articles.first(where: { $0.articleID == articleSpecifier.articleID }) else {
|
||||
return
|
||||
}
|
||||
selectArticle(article)
|
||||
}
|
||||
|
||||
func handle(_ activity: NSUserActivity) {
|
||||
@@ -889,18 +902,19 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
|
||||
func selectArticle(_ article: Article?, animations: Animations = [], isShowingExtractedArticle: Bool? = nil, articleWindowScrollY: Int? = nil) {
|
||||
guard article != currentArticle else { return }
|
||||
|
||||
|
||||
currentArticle = article
|
||||
activityManager.reading(feed: timelineFeed, article: article)
|
||||
|
||||
|
||||
if article == nil {
|
||||
rootSplitViewController.show(.supplementary)
|
||||
mainTimelineViewController?.updateArticleSelection(animations: animations)
|
||||
AppDefaults.shared.selectedArticle = nil
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
rootSplitViewController.show(.secondary)
|
||||
|
||||
|
||||
// Mark article as read before navigating to it, so the read status does not flash unread/read on display
|
||||
markArticles(Set([article!]), statusKey: .read, flag: true)
|
||||
|
||||
@@ -909,6 +923,8 @@ final class SceneCoordinator: NSObject, UndoableCommandRunner {
|
||||
if let isShowingExtractedArticle = isShowingExtractedArticle, let articleWindowScrollY = articleWindowScrollY {
|
||||
articleViewController?.restoreScrollPosition = (isShowingExtractedArticle, articleWindowScrollY)
|
||||
}
|
||||
|
||||
AppDefaults.shared.selectedArticle = ArticleSpecifier(article: article!)
|
||||
}
|
||||
|
||||
func beginSearching() {
|
||||
|
||||
Reference in new issue
Block a user