Get the app delegate the old-fashioned way.

This commit is contained in:
Brent Simmons 2024-06-30 18:06:49 -07:00
parent 512aee6ce8
commit e990b7aab1
3 changed files with 12 additions and 4 deletions

View File

@ -578,6 +578,7 @@ extension MainWindowController: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
detailViewController?.stopMediaPlayback()
let appDelegate = NSApp.delegate as! AppDelegate
appDelegate.removeMainWindow(self)
}
@ -1248,7 +1249,8 @@ private extension MainWindowController {
}
guard let selectedObjects = selectedObjectsInSidebar(), selectedObjects.count > 0 else {
window?.title = appDelegate.appName!
window?.title = AppConfig.appName
let appDelegate = NSApp.delegate as! AppDelegate
setSubtitle(appDelegate.unreadCount)
return
}

View File

@ -467,6 +467,8 @@ private extension SidebarOutlineDataSource {
return false
}
let appDelegate = NSApp.delegate as! AppDelegate
// Show the add-feed sheet.
if let account = parentNode.representedObject as? Account {
appDelegate.addFeed(draggedFeed.url, name: draggedFeed.editedName ?? draggedFeed.name, account: account, folder: nil)

View File

@ -25,11 +25,15 @@ extension NSApplication : ScriptingObjectContainer {
var scriptingKey: String {
return "application"
}
private var scriptingAppDelegate: ScriptingAppDelegate {
NSApp.delegate as! ScriptingAppDelegate
}
@objc(currentArticle)
func currentArticle() -> ScriptableArticle? {
var scriptableArticle: ScriptableArticle?
if let currentArticle = appDelegate.scriptingCurrentArticle {
if let currentArticle = scriptingAppDelegate.scriptingCurrentArticle {
if let feed = currentArticle.feed {
let scriptableFeed = ScriptableFeed(feed, container:self)
scriptableArticle = ScriptableArticle(currentArticle, container:scriptableFeed)
@ -40,7 +44,7 @@ extension NSApplication : ScriptingObjectContainer {
@objc(selectedArticles)
func selectedArticles() -> NSArray {
let articles = appDelegate.scriptingSelectedArticles
let articles = scriptingAppDelegate.scriptingSelectedArticles
let scriptableArticles:[ScriptableArticle] = articles.compactMap { article in
if let feed = article.feed {
let scriptableFeed = ScriptableFeed(feed, container:self)