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) { func windowWillClose(_ notification: Notification) {
detailViewController?.stopMediaPlayback() detailViewController?.stopMediaPlayback()
let appDelegate = NSApp.delegate as! AppDelegate
appDelegate.removeMainWindow(self) appDelegate.removeMainWindow(self)
} }
@ -1248,7 +1249,8 @@ private extension MainWindowController {
} }
guard let selectedObjects = selectedObjectsInSidebar(), selectedObjects.count > 0 else { 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) setSubtitle(appDelegate.unreadCount)
return return
} }

View File

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

View File

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