Fix some build errors.

This commit is contained in:
Brent Simmons 2017-09-17 12:54:08 -07:00
parent 1b391c262e
commit c0ce68e64b
17 changed files with 69 additions and 62 deletions

View File

@ -66,7 +66,7 @@ public final class ArticleStylesManager {
updateStyleNames() updateStyleNames()
updateCurrentStyle() updateCurrentStyle()
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: NSNotification.Name.NSApplication.didBecomeActiveNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: NSNotification.Name.NSApplicationDidBecomeActiveNotification, object: nil)
} }
// MARK: Notifications // MARK: Notifications

View File

@ -12,51 +12,39 @@ import Account
// These handle multiple accounts. // These handle multiple accounts.
func markArticles(_ articles: NSSet, statusKey: ArticleStatusKey, flag: Bool) { func markArticles(_ articles: Set<Article>, statusKey: String, flag: Bool) {
let d: [String: NSSet] = accountAndArticlesDictionary(articles) let d: [String: Set<Article>] = accountAndArticlesDictionary(articles)
d.keys.forEach { (oneAccountIdentifier) in d.keys.forEach { (accountID) in
guard let oneAccountArticles = d[oneAccountIdentifier], let oneAccount = accountWithIdentifier(oneAccountIdentifier) else { guard let accountArticles = d[accountID], let account = accountWithID(accountID) else {
return return
} }
oneAccount.markArticles(oneAccountArticles, statusKey: statusKey, flag: flag) account.markArticles(accountArticles, statusKey: statusKey, flag: flag)
} }
} }
private func accountAndArticlesDictionary(_ articles: NSSet) -> [String: NSSet] { private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String: Set<Article>] {
var d = [String: NSMutableSet]() var d = [String: Set<Article>]()
articles.forEach { (oneObject) in articles.forEach { (article) in
guard let oneArticle = oneObject as? Article else { let accountID = article.accountID
return var articleSet: Set<Article> = d[accountID] ?? Set<Article>()
} articleSet.insert(article)
guard let oneAccountIdentifier = oneArticle.account?.accountID else { d[accountID] = articleSet
return
}
let oneArticleSet: NSMutableSet = d[oneAccountIdentifier] ?? NSMutableSet()
oneArticleSet.add(oneArticle)
d[oneAccountIdentifier] = oneArticleSet
} }
return d return d
} }
private func accountWithID(_ accountID: String) -> Account? { extension Article {
return AccountManager.sharedInstance.existingAccountWithIdentifier(accountID) func preferredLink() -> String? {
return url ?? externalURL
} }
func preferredLink(for article: Article) -> String? {
if let s = article.permalink {
return s
} }
return article.link
}

View File

@ -58,7 +58,7 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
func addFeedWindowController(_: AddFeedWindowController, userEnteredURL url: URL, userEnteredTitle title: String?, folder: Folder) { func addFeedWindowController(_: AddFeedWindowController, userEnteredURL url: URL, userEnteredTitle title: String?, folder: Folder) {
closeAddFeedSheet(NSModalResponseOK) closeAddFeedSheet(NSApplication.ModalResponse.OK)
assert(folder.account != nil, "Folder must have an account.") assert(folder.account != nil, "Folder must have an account.")
let account = folder.account ?? AccountManager.sharedInstance.localAccount let account = folder.account ?? AccountManager.sharedInstance.localAccount
@ -77,7 +77,7 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
func addFeedWindowControllerUserDidCancel(_: AddFeedWindowController) { func addFeedWindowControllerUserDidCancel(_: AddFeedWindowController) {
closeAddFeedSheet(NSModalResponseCancel) closeAddFeedSheet(NSApplication.ModalResponse.cancel)
} }
// MARK: FeedFinderDelegate // MARK: FeedFinderDelegate
@ -128,14 +128,14 @@ private extension AddFeedController {
var urlStringFromPasteboard: String? { var urlStringFromPasteboard: String? {
get { get {
if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general()) { if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) {
return urlString.rs_normalizedURL() return urlString.rs_normalizedURL()
} }
return nil return nil
} }
} }
func closeAddFeedSheet(_ returnCode: NSModalResponse) { func closeAddFeedSheet(_ returnCode: NSApplication.ModalResponse) {
if let sheetWindow = addFeedWindowController?.window { if let sheetWindow = addFeedWindowController?.window {
hostWindow.endSheet(sheetWindow, returnCode: returnCode) hostWindow.endSheet(sheetWindow, returnCode: returnCode)

View File

@ -112,7 +112,7 @@ class AddFeedWindowController : NSWindowController {
@IBAction func localShowFeedList(_ sender: AnyObject) { @IBAction func localShowFeedList(_ sender: AnyObject) {
NSApplication.shared.sendAction(NSSelectorFromString("showFeedList:"), to: nil, from: sender) NSApplication.shared.sendAction(NSSelectorFromString("showFeedList:"), to: nil, from: sender)
hostWindow.endSheet(window!, returnCode: NSModalResponseContinue) hostWindow.endSheet(window!, returnCode: NSApplication.ModalResponse.continue)
} }
// MARK: NSTextFieldDelegate // MARK: NSTextFieldDelegate

View File

@ -8,6 +8,7 @@
import Cocoa import Cocoa
import Data import Data
import Account
//func addFolderWindowController() -> AddFolderWindowController { //func addFolderWindowController() -> AddFolderWindowController {
// //
@ -22,7 +23,7 @@ class AddFolderWindowController : NSWindowController {
convenience init() { convenience init() {
self.init(windowNibName: "AddFolderSheet") self.init(windowNibName: NSNib.Name(rawValue: "AddFolderSheet"))
} }
// MARK: API // MARK: API
@ -30,9 +31,9 @@ class AddFolderWindowController : NSWindowController {
func runSheetOnWindow(_ w: NSWindow) { func runSheetOnWindow(_ w: NSWindow) {
hostWindow = w hostWindow = w
hostWindow!.beginSheet(window!) { (returnCode: NSModalResponse) -> Void in hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
if returnCode == NSModalResponseOK { if returnCode == NSApplication.ModalResponse.OK {
self.addFolderIfNeeded() self.addFolderIfNeeded()
} }
} }
@ -74,12 +75,12 @@ class AddFolderWindowController : NSWindowController {
@IBAction func cancel(_ sender: AnyObject) { @IBAction func cancel(_ sender: AnyObject) {
hostWindow!.endSheet(window!, returnCode: NSModalResponseCancel) hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
} }
@IBAction func addFolder(_ sender: AnyObject) { @IBAction func addFolder(_ sender: AnyObject) {
hostWindow!.endSheet(window!, returnCode: NSModalResponseOK) hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
} }
} }

View File

@ -48,7 +48,7 @@ class DetailViewController: NSViewController, WKNavigationDelegate, WKUIDelegate
// MARK: Notifications // MARK: Notifications
func timelineSelectionDidChange(_ note: Notification) { @objc func timelineSelectionDidChange(_ note: Notification) {
let timelineView = note.userInfo?[viewKey] as! NSView let timelineView = note.userInfo?[viewKey] as! NSView

View File

@ -20,7 +20,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
super.windowDidLoad() super.windowDidLoad()
// window?.titleVisibility = .hidden // window?.titleVisibility = .hidden
window?.setFrameUsingName(kWindowFrameKey, force: true) window?.setFrameUsingName(NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey), force: true)
detailSplitViewItem?.minimumThickness = 384 detailSplitViewItem?.minimumThickness = 384
@ -33,12 +33,12 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
// MARK: Notifications // MARK: Notifications
func applicationWillTerminate(_ note: Notification) { @objc func applicationWillTerminate(_ note: Notification) {
window?.saveFrame(usingName: kWindowFrameKey) window?.saveFrame(usingName: NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey))
} }
func appNavigationKeyPressed(_ note: Notification) { @objc func appNavigationKeyPressed(_ note: Notification) {
guard let key = note.userInfo?[appNavigationKey] as? Int else { guard let key = note.userInfo?[appNavigationKey] as? Int else {
return return
@ -50,14 +50,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
print(key) print(key)
} }
func refreshProgressDidChange(_ note: Notification) { @objc func refreshProgressDidChange(_ note: Notification) {
rs_performSelectorCoalesced(#selector(MainWindowController.coalescedMakeToolbarValidate(_:)), with: nil, afterDelay: 0.1) rs_performSelectorCoalesced(#selector(MainWindowController.coalescedMakeToolbarValidate(_:)), with: nil, afterDelay: 0.1)
} }
// MARK: Toolbar // MARK: Toolbar
func coalescedMakeToolbarValidate(_ sender: Any) { @objc func coalescedMakeToolbarValidate(_ sender: Any) {
window?.toolbar?.validateVisibleItems() window?.toolbar?.validateVisibleItems()
} }

View File

@ -103,14 +103,14 @@ import Account
outlineView.selectRowIndexes(IndexSet([row]), byExtendingSelection: false) outlineView.selectRowIndexes(IndexSet([row]), byExtendingSelection: false)
NSApplication.shared().sendAction(NSSelectorFromString("nextUnread:"), to: nil, from: self) NSApplication.shared.sendAction(NSSelectorFromString("nextUnread:"), to: nil, from: self)
} }
// MARK: NSOutlineViewDelegate // MARK: NSOutlineViewDelegate
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? { func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
let cell = outlineView.make(withIdentifier: "DataCell", owner: self) as! SidebarCell let cell = outlineView.make(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "DataCell"), owner: self) as! SidebarCell
let node = item as! Node let node = item as! Node
configure(cell, node) configure(cell, node)

View File

@ -33,7 +33,7 @@ final class StatusBarView: NSView {
override func awakeFromNib() { override func awakeFromNib() {
let progressLabelFontSize = progressLabel.font?.pointSize ?? 13.0 let progressLabelFontSize = progressLabel.font?.pointSize ?? 13.0
progressLabel.font = NSFont.monospacedDigitSystemFont(ofSize: progressLabelFontSize, weight: NSFontWeightRegular) progressLabel.font = NSFont.monospacedDigitSystemFont(ofSize: progressLabelFontSize, weight: NSFont.Weight.regular)
progressLabel.stringValue = "" progressLabel.stringValue = ""
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
@ -91,7 +91,7 @@ private extension StatusBarView {
return return
} }
let s = preferredLink(for: article) let s = article.preferredLink()
if let s = s { if let s = s {
urlLabel.stringValue = (s as NSString).rs_stringByStrippingHTTPOrHTTPSScheme() urlLabel.stringValue = (s as NSString).rs_stringByStrippingHTTPOrHTTPSScheme()
} }

View File

@ -8,6 +8,7 @@
import Foundation import Foundation
import Data import Data
import RSParser
private let truncatedFeedNameCache = NSMutableDictionary() private let truncatedFeedNameCache = NSMutableDictionary()
private let truncatedTitleCache = NSMutableDictionary() private let truncatedTitleCache = NSMutableDictionary()
@ -102,7 +103,7 @@ func timelineNormalizedTextTruncated(_ text: String) -> String {
return cachedText return cachedText
} }
var s: NSString = (text as NSString).rs_stringByDecodingHTMLEntities() as NSString var s: NSString = (text as NSString).rsparser_stringByDecodingHTMLEntities() as NSString
s = s.rs_stringByTrimmingWhitespace() as NSString s = s.rs_stringByTrimmingWhitespace() as NSString
s = s.rs_stringWithCollapsedWhitespace() as NSString s = s.rs_stringWithCollapsedWhitespace() as NSString

View File

@ -78,7 +78,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
NotificationCenter.default.addObserver(self, selector: #selector(sidebarSelectionDidChange(_:)), name: .SidebarSelectionDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(sidebarSelectionDidChange(_:)), name: .SidebarSelectionDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleStatusesDidChange(_:)), name: .ArticleStatusesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(articleStatusesDidChange(_:)), name: .ArticleStatusesDidChange, object: nil)
NSUserDefaultsController.shared().addObserver(self, forKeyPath:timelineFontSizeKVOKey, options: NSKeyValueObservingOptions(rawValue: 0), context: nil) NSUserDefaultsController.shared.addObserver(self, forKeyPath:timelineFontSizeKVOKey, options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
didRegisterForNotifications = true didRegisterForNotifications = true
} }
@ -133,7 +133,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
// MARK: Actions // MARK: Actions
func openArticleInBrowser(_ sender: AnyObject) { @objc func openArticleInBrowser(_ sender: AnyObject) {
guard let article = oneSelectedArticle else { guard let article = oneSelectedArticle else {
return return
@ -221,7 +221,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
// MARK: Notifications // MARK: Notifications
func sidebarSelectionDidChange(_ note: Notification) { @objc func sidebarSelectionDidChange(_ note: Notification) {
let sidebarView = note.userInfo?[viewKey] as! NSView let sidebarView = note.userInfo?[viewKey] as! NSView
@ -230,7 +230,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
} }
} }
func articleStatusesDidChange(_ note: Notification) { @objc func articleStatusesDidChange(_ note: Notification) {
guard let articles = note.userInfo?[articlesKey] as? NSSet else { guard let articles = note.userInfo?[articlesKey] as? NSSet else {
return return

View File

@ -16,7 +16,7 @@ class IndeterminateProgressWindowController: NSWindowController {
convenience init(message: String) { convenience init(message: String) {
self.init(windowNibName: "IndeterminateProgressWindow") self.init(windowNibName: NSNib.Name(rawValue: "IndeterminateProgressWindow"))
self.message = message self.message = message
} }
@ -29,10 +29,10 @@ class IndeterminateProgressWindowController: NSWindowController {
func runIndeterminateProgressWithMessage(_ message: String) { func runIndeterminateProgressWithMessage(_ message: String) {
let windowController = IndeterminateProgressWindowController(message: message) let windowController = IndeterminateProgressWindowController(message: message)
NSApplication.shared().runModal(for: windowController.window!) NSApplication.shared.runModal(for: windowController.window!)
} }
func stopIndeterminateProgress() { func stopIndeterminateProgress() {
NSApplication.shared().stopModal() NSApplication.shared.stopModal()
} }

View File

@ -65,6 +65,11 @@ public final class Account: DisplayNameProvider, Hashable {
// TODO // TODO
} }
public func markArticles(_ articles: Set<Article>, statusKey: String, flag: Bool) {
// TODO
}
// MARK: - Equatable // MARK: - Equatable
public class func ==(lhs: Account, rhs: Account) -> Bool { public class func ==(lhs: Account, rhs: Account) -> Bool {

View File

@ -34,7 +34,7 @@ public final class AccountManager: UnreadCountProvider {
} }
} }
var sortedAccounts: [Account] { public var sortedAccounts: [Account] {
get { get {
return accountsSortedByName() return accountsSortedByName()
} }
@ -191,6 +191,12 @@ private func accountFilePathWithFolder(_ folderPath: String) -> String {
return NSString(string: folderPath).appendingPathComponent(accountDataFileName) return NSString(string: folderPath).appendingPathComponent(accountDataFileName)
} }
public func accountWithID(_ accountID: String) -> Account? {
// Shortcut.
return AccountManager.sharedInstance.existingAccountWithID(accountID)
}
private struct AccountSpecifier { private struct AccountSpecifier {
let type: String let type: String

View File

@ -13,7 +13,7 @@ public extension Article {
var account: Account? { var account: Account? {
get { get {
return AccountManager.sharedInstance.existingAccountWithID(accountID) return accountWithID(accountID)
} }
} }
} }

View File

@ -13,7 +13,7 @@ public extension Feed {
var account: Account? { var account: Account? {
get { get {
return AccountManager.sharedInstance.existingAccountWithID(accountID) return accountWithID(accountID)
} }
} }
} }

View File

@ -14,6 +14,12 @@ public final class Folder: DisplayNameProvider, UnreadCountProvider {
public let accountID: String public let accountID: String
var childObjects = [AnyObject]() var childObjects = [AnyObject]()
public var account: Account? {
get {
return accountWithID(accountID)
}
}
// MARK: - DisplayNameProvider // MARK: - DisplayNameProvider
public var nameForDisplay: String public var nameForDisplay: String