mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add the ability to handoff from iOS to Mac
This commit is contained in:
@@ -18,6 +18,8 @@ enum TimelineSourceMode {
|
||||
|
||||
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
|
||||
private var activityManager = ActivityManager()
|
||||
|
||||
private var isShowingExtractedArticle = false
|
||||
private var articleExtractor: ArticleExtractor? = nil
|
||||
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
|
||||
@@ -119,6 +121,12 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
currentTimelineViewController?.goToDeepLink(for: userInfo)
|
||||
}
|
||||
|
||||
func handle(_ activity: NSUserActivity) {
|
||||
guard let userInfo = activity.userInfo else { return }
|
||||
sidebarViewController?.deepLinkRevealAndSelect(for: userInfo)
|
||||
currentTimelineViewController?.goToDeepLink(for: userInfo)
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
// func window(_ window: NSWindow, willEncodeRestorableState state: NSCoder) {
|
||||
@@ -456,6 +464,8 @@ extension MainWindowController: SidebarDelegate {
|
||||
extension MainWindowController: TimelineContainerViewControllerDelegate {
|
||||
|
||||
func timelineSelectionDidChange(_: TimelineContainerViewController, articles: [Article]?, mode: TimelineSourceMode) {
|
||||
activityManager.invalidateReading()
|
||||
|
||||
articleExtractor?.cancel()
|
||||
articleExtractor = nil
|
||||
isShowingExtractedArticle = false
|
||||
@@ -464,6 +474,7 @@ extension MainWindowController: TimelineContainerViewControllerDelegate {
|
||||
let detailState: DetailState
|
||||
if let articles = articles {
|
||||
if articles.count == 1 {
|
||||
activityManager.reading(articles.first!)
|
||||
if articles.first?.feed?.isArticleExtractorAlwaysOn ?? false {
|
||||
detailState = .loading
|
||||
startArticleExtractorForCurrentLink()
|
||||
|
||||
Reference in New Issue
Block a user