Remove extraneous get { from a bunch of read-only accessors.
This commit is contained in:
parent
192439abe7
commit
2f21dbf6be
@ -17,9 +17,7 @@ final class DeleteFromSidebarCommand: UndoableCommand {
|
||||
let undoManager: UndoManager
|
||||
let undoActionName: String
|
||||
var redoActionName: String {
|
||||
get {
|
||||
return undoActionName
|
||||
}
|
||||
return undoActionName
|
||||
}
|
||||
|
||||
private let itemSpecifiers: [SidebarItemSpecifier]
|
||||
@ -94,15 +92,13 @@ private struct SidebarItemSpecifier {
|
||||
private let path: ContainerPath
|
||||
|
||||
private var container: Container? {
|
||||
get {
|
||||
if let parentFolder = parentFolder {
|
||||
return parentFolder
|
||||
}
|
||||
if let account = account {
|
||||
return account
|
||||
}
|
||||
return nil
|
||||
if let parentFolder = parentFolder {
|
||||
return parentFolder
|
||||
}
|
||||
if let account = account {
|
||||
return account
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
init?(node: Node) {
|
||||
|
@ -42,26 +42,18 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
|
||||
extension Article {
|
||||
|
||||
var feed: Feed? {
|
||||
get {
|
||||
return account?.existingFeed(with: feedID)
|
||||
}
|
||||
return account?.existingFeed(with: feedID)
|
||||
}
|
||||
|
||||
var preferredLink: String? {
|
||||
get {
|
||||
return url ?? externalURL
|
||||
}
|
||||
return url ?? externalURL
|
||||
}
|
||||
|
||||
var body: String? {
|
||||
get {
|
||||
return contentHTML ?? contentText ?? summary
|
||||
}
|
||||
return contentHTML ?? contentText ?? summary
|
||||
}
|
||||
|
||||
var logicalDatePublished: Date {
|
||||
get {
|
||||
return datePublished ?? dateModified ?? status.dateArrived
|
||||
}
|
||||
return datePublished ?? dateModified ?? status.dateArrived
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,7 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
|
||||
}
|
||||
|
||||
var nameForDisplay: String { // DisplayNameProvider
|
||||
get {
|
||||
return name
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
init(name: String, url: String, homePageURL: String) {
|
||||
|
@ -17,9 +17,7 @@ final class FeedListFolder: Hashable, DisplayNameProvider {
|
||||
let hashValue: Int
|
||||
|
||||
var nameForDisplay: String { // DisplayNameProvider
|
||||
get {
|
||||
return name
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
init(name: String, feeds: Set<FeedListFeed>) {
|
||||
|
@ -33,9 +33,7 @@ final class InspectorWindowController: NSWindowController {
|
||||
}
|
||||
|
||||
var isOpen: Bool {
|
||||
get {
|
||||
return isWindowLoaded && window!.isVisible
|
||||
}
|
||||
return isWindowLoaded && window!.isVisible
|
||||
}
|
||||
|
||||
private var inspectors: [InspectorViewController]!
|
||||
|
@ -126,14 +126,12 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
|
||||
private extension AddFeedController {
|
||||
|
||||
var urlStringFromPasteboard: String? {
|
||||
get {
|
||||
if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) {
|
||||
return urlString.rs_normalizedURL()
|
||||
}
|
||||
return nil
|
||||
if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) {
|
||||
return urlString.rs_normalizedURL()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
struct AccountAndFolderSpecifier {
|
||||
let account: Account
|
||||
let folder: Folder?
|
||||
|
@ -33,14 +33,12 @@ class AddFeedWindowController : NSWindowController {
|
||||
fileprivate var folderTreeController: TreeController!
|
||||
|
||||
private var userEnteredTitle: String? {
|
||||
get {
|
||||
var s = nameTextField.stringValue
|
||||
s = s.rs_stringWithCollapsedWhitespace()
|
||||
if s.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return s
|
||||
var s = nameTextField.stringValue
|
||||
s = s.rs_stringWithCollapsedWhitespace()
|
||||
if s.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
var hostWindow: NSWindow!
|
||||
|
@ -9,12 +9,10 @@
|
||||
import AppKit
|
||||
|
||||
class MainWindowSplitView: NSSplitView {
|
||||
|
||||
|
||||
private let splitViewDividerColor = NSColor(calibratedWhite: 0.65, alpha: 1.0)
|
||||
|
||||
|
||||
override var dividerColor: NSColor {
|
||||
get {
|
||||
return splitViewDividerColor
|
||||
}
|
||||
return splitViewDividerColor
|
||||
}
|
||||
}
|
||||
|
@ -75,9 +75,7 @@ class SidebarCell : NSTableCellView {
|
||||
}
|
||||
|
||||
override var isFlipped: Bool {
|
||||
get {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private func commonInit() {
|
||||
|
@ -25,11 +25,9 @@ final class SidebarStatusBarView: NSView {
|
||||
}
|
||||
|
||||
override var isFlipped: Bool {
|
||||
get {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
||||
progressIndicator.isHidden = true
|
||||
|
@ -27,36 +27,30 @@ class UnreadCountView : NSView {
|
||||
}
|
||||
}
|
||||
var unreadCountString: String {
|
||||
get {
|
||||
return unreadCount < 1 ? "" : "\(unreadCount)"
|
||||
}
|
||||
return unreadCount < 1 ? "" : "\(unreadCount)"
|
||||
}
|
||||
|
||||
private var intrinsicContentSizeIsValid = false
|
||||
private var _intrinsicContentSize = NSZeroSize
|
||||
|
||||
override var intrinsicContentSize: NSSize {
|
||||
get {
|
||||
if !intrinsicContentSizeIsValid {
|
||||
var size = NSZeroSize
|
||||
if unreadCount > 0 {
|
||||
size = textSize()
|
||||
size.width += (padding.left + padding.right)
|
||||
size.height += (padding.top + padding.bottom)
|
||||
}
|
||||
_intrinsicContentSize = size
|
||||
intrinsicContentSizeIsValid = true
|
||||
if !intrinsicContentSizeIsValid {
|
||||
var size = NSZeroSize
|
||||
if unreadCount > 0 {
|
||||
size = textSize()
|
||||
size.width += (padding.left + padding.right)
|
||||
size.height += (padding.top + padding.bottom)
|
||||
}
|
||||
return _intrinsicContentSize
|
||||
_intrinsicContentSize = size
|
||||
intrinsicContentSizeIsValid = true
|
||||
}
|
||||
return _intrinsicContentSize
|
||||
}
|
||||
|
||||
override var isFlipped: Bool {
|
||||
get {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
override func invalidateIntrinsicContentSize() {
|
||||
|
||||
intrinsicContentSizeIsValid = false
|
||||
|
@ -23,14 +23,12 @@ class TimelineTableRowView : NSTableRowView {
|
||||
// }
|
||||
|
||||
private var cellView: TimelineTableCellView? {
|
||||
get {
|
||||
for oneSubview in subviews {
|
||||
if let foundView = oneSubview as? TimelineTableCellView {
|
||||
return foundView
|
||||
}
|
||||
for oneSubview in subviews {
|
||||
if let foundView = oneSubview as? TimelineTableCellView {
|
||||
return foundView
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
override var isEmphasized: Bool {
|
||||
@ -50,10 +48,7 @@ class TimelineTableRowView : NSTableRowView {
|
||||
}
|
||||
|
||||
var gridRect: NSRect {
|
||||
get {
|
||||
// return NSMakeRect(floor(cellAppearance.boxLeftMargin), NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
|
||||
return NSMakeRect(0.0, NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
|
||||
}
|
||||
return NSMakeRect(0.0, NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
|
||||
}
|
||||
|
||||
override func drawSeparator(in dirtyRect: NSRect) {
|
||||
|
@ -18,15 +18,11 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
|
||||
|
||||
var selectedArticles: [Article] {
|
||||
get {
|
||||
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
|
||||
}
|
||||
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
|
||||
}
|
||||
|
||||
var hasAtLeastOneSelectedArticle: Bool {
|
||||
get {
|
||||
return tableView.selectedRow != -1
|
||||
}
|
||||
return tableView.selectedRow != -1
|
||||
}
|
||||
|
||||
var articles = ArticleArray() {
|
||||
@ -105,9 +101,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
private var oneSelectedArticle: Article? {
|
||||
get {
|
||||
return selectedArticles.count == 1 ? selectedArticles.first : nil
|
||||
}
|
||||
return selectedArticles.count == 1 ? selectedArticles.first : nil
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
@ -96,9 +96,7 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
|
||||
private extension PreferencesWindowController {
|
||||
|
||||
var currentView: NSView? {
|
||||
get {
|
||||
return window?.contentView?.subviews.first
|
||||
}
|
||||
return window?.contentView?.subviews.first
|
||||
}
|
||||
|
||||
func toolbarItemSpec(for identifier: String) -> PreferencesToolbarItemSpec? {
|
||||
|
@ -22,8 +22,6 @@ private var smartFeedIcon: NSImage = {
|
||||
extension PseudoFeed {
|
||||
|
||||
var smallIcon: NSImage? {
|
||||
get {
|
||||
return smartFeedIcon
|
||||
}
|
||||
return smartFeedIcon
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ protocol SmartFeedDelegate: DisplayNameProvider, ArticleFetcher {
|
||||
final class SmartFeed: PseudoFeed {
|
||||
|
||||
var nameForDisplay: String {
|
||||
get {
|
||||
return delegate.nameForDisplay
|
||||
}
|
||||
return delegate.nameForDisplay
|
||||
}
|
||||
|
||||
var unreadCount = 0 {
|
||||
|
@ -102,19 +102,15 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
}
|
||||
|
||||
var refreshProgress: DownloadProgress {
|
||||
get {
|
||||
return delegate.refreshProgress
|
||||
}
|
||||
return delegate.refreshProgress
|
||||
}
|
||||
|
||||
|
||||
var supportsSubFolders: Bool {
|
||||
get {
|
||||
return delegate.supportsSubFolders
|
||||
}
|
||||
return delegate.supportsSubFolders
|
||||
}
|
||||
|
||||
|
||||
init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) {
|
||||
|
||||
|
||||
// TODO: support various syncing systems.
|
||||
precondition(type == .onMyMac)
|
||||
self.delegate = LocalAccountDelegate()
|
||||
|
@ -31,37 +31,29 @@ public final class AccountManager: UnreadCountProvider {
|
||||
}
|
||||
|
||||
public var accounts: [Account] {
|
||||
get {
|
||||
return Array(accountsDictionary.values)
|
||||
}
|
||||
return Array(accountsDictionary.values)
|
||||
}
|
||||
|
||||
public var sortedAccounts: [Account] {
|
||||
get {
|
||||
return accountsSortedByName()
|
||||
}
|
||||
return accountsSortedByName()
|
||||
}
|
||||
|
||||
public var refreshInProgress: Bool {
|
||||
get {
|
||||
for account in accounts {
|
||||
if account.refreshInProgress {
|
||||
return true
|
||||
}
|
||||
for account in accounts {
|
||||
if account.refreshInProgress {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
public var combinedRefreshProgress: CombinedRefreshProgress {
|
||||
get {
|
||||
let downloadProgressArray = accounts.map { $0.refreshProgress }
|
||||
return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
|
||||
}
|
||||
let downloadProgressArray = accounts.map { $0.refreshProgress }
|
||||
return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
|
||||
}
|
||||
|
||||
|
||||
public init() {
|
||||
|
||||
|
||||
// The local "On My Mac" account must always exist, even if it's empty.
|
||||
|
||||
let localAccountFolder = (accountsFolder as NSString).appendingPathComponent("OnMyMac")
|
||||
|
@ -18,9 +18,7 @@ public extension Notification.Name {
|
||||
public extension Feed {
|
||||
|
||||
public var account: Account? {
|
||||
get {
|
||||
return AccountManager.shared.existingAccount(with: accountID)
|
||||
}
|
||||
return AccountManager.shared.existingAccount(with: accountID)
|
||||
}
|
||||
|
||||
public func takeSettings(from parsedFeed: ParsedFeed) {
|
||||
@ -59,15 +57,11 @@ public extension Feed {
|
||||
public extension Article {
|
||||
|
||||
public var account: Account? {
|
||||
get {
|
||||
return AccountManager.shared.existingAccount(with: accountID)
|
||||
}
|
||||
return AccountManager.shared.existingAccount(with: accountID)
|
||||
}
|
||||
|
||||
public var feed: Feed? {
|
||||
get {
|
||||
return account?.existingFeed(with: feedID)
|
||||
}
|
||||
return account?.existingFeed(with: feedID)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
let supportsSubFolders = false
|
||||
|
||||
var refreshProgress: DownloadProgress {
|
||||
get {
|
||||
return DownloadProgress(numberOfTasks: 0) // TODO
|
||||
}
|
||||
return DownloadProgress(numberOfTasks: 0) // TODO
|
||||
}
|
||||
|
||||
func refreshAll(for: Account) {
|
||||
|
@ -29,10 +29,7 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
|
||||
// MARK: - DisplayNameProvider
|
||||
|
||||
public var nameForDisplay: String {
|
||||
get {
|
||||
return name ?? Folder.untitledName
|
||||
|
||||
}
|
||||
return name ?? Folder.untitledName
|
||||
}
|
||||
|
||||
// MARK: - UnreadCountProvider
|
||||
@ -84,38 +81,36 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
|
||||
}
|
||||
|
||||
var dictionary: [String: Any] {
|
||||
get {
|
||||
|
||||
var d = [String: Any]()
|
||||
guard let account = account else {
|
||||
return d
|
||||
}
|
||||
|
||||
if let name = name {
|
||||
d[Key.name] = name
|
||||
}
|
||||
if unreadCount > 0 {
|
||||
d[Key.unreadCount] = unreadCount
|
||||
}
|
||||
|
||||
let childObjects = children.compactMap { (child) -> [String: Any]? in
|
||||
|
||||
if let feed = child as? Feed {
|
||||
return feed.dictionary
|
||||
}
|
||||
if let folder = child as? Folder, account.supportsSubFolders {
|
||||
return folder.dictionary
|
||||
}
|
||||
assertionFailure("Expected a feed or a folder.");
|
||||
return nil
|
||||
}
|
||||
|
||||
if !childObjects.isEmpty {
|
||||
d[Key.children] = childObjects
|
||||
}
|
||||
|
||||
|
||||
var d = [String: Any]()
|
||||
guard let account = account else {
|
||||
return d
|
||||
}
|
||||
|
||||
if let name = name {
|
||||
d[Key.name] = name
|
||||
}
|
||||
if unreadCount > 0 {
|
||||
d[Key.unreadCount] = unreadCount
|
||||
}
|
||||
|
||||
let childObjects = children.compactMap { (child) -> [String: Any]? in
|
||||
|
||||
if let feed = child as? Feed {
|
||||
return feed.dictionary
|
||||
}
|
||||
if let folder = child as? Folder, account.supportsSubFolders {
|
||||
return folder.dictionary
|
||||
}
|
||||
assertionFailure("Expected a feed or a folder.");
|
||||
return nil
|
||||
}
|
||||
|
||||
if !childObjects.isEmpty {
|
||||
d[Key.children] = childObjects
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
// MARK: Feeds
|
||||
|
@ -15,9 +15,7 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||
private let refresher = LocalAccountRefresher()
|
||||
|
||||
var refreshProgress: DownloadProgress {
|
||||
get {
|
||||
return refresher.progress
|
||||
}
|
||||
return refresher.progress
|
||||
}
|
||||
|
||||
func refreshAll(for account: Account) {
|
||||
|
@ -19,9 +19,7 @@ final class LocalAccountRefresher {
|
||||
}()
|
||||
|
||||
var progress: DownloadProgress {
|
||||
get {
|
||||
return downloadSession.progress
|
||||
}
|
||||
return downloadSession.progress
|
||||
}
|
||||
|
||||
public func refreshFeeds(_ feeds: Set<Feed>) {
|
||||
|
@ -34,15 +34,13 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
||||
// MARK: - DisplayNameProvider
|
||||
|
||||
public var nameForDisplay: String {
|
||||
get {
|
||||
if let s = editedName, !s.isEmpty {
|
||||
return s
|
||||
}
|
||||
if let s = name, !s.isEmpty {
|
||||
return s
|
||||
}
|
||||
return NSLocalizedString("Untitled", comment: "Feed name")
|
||||
if let s = editedName, !s.isEmpty {
|
||||
return s
|
||||
}
|
||||
if let s = name, !s.isEmpty {
|
||||
return s
|
||||
}
|
||||
return NSLocalizedString("Untitled", comment: "Feed name")
|
||||
}
|
||||
|
||||
// MARK: - UnreadCountProvider
|
||||
@ -115,46 +113,44 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
||||
}
|
||||
|
||||
public var dictionary: [String: Any] {
|
||||
get {
|
||||
var d = [String: Any]()
|
||||
|
||||
d[Key.url] = url
|
||||
|
||||
// feedID is not repeated when it’s the same as url
|
||||
if (feedID != url) {
|
||||
d[Key.feedID] = feedID
|
||||
}
|
||||
|
||||
if let homePageURL = homePageURL {
|
||||
d[Key.homePageURL] = homePageURL
|
||||
}
|
||||
if let iconURL = iconURL {
|
||||
d[Key.iconURL] = iconURL
|
||||
}
|
||||
if let faviconURL = faviconURL {
|
||||
d[Key.faviconURL] = faviconURL
|
||||
}
|
||||
if let name = name {
|
||||
d[Key.name] = name
|
||||
}
|
||||
if let editedName = editedName {
|
||||
d[Key.editedName] = editedName
|
||||
}
|
||||
if let authorsArray = authors?.diskArray() {
|
||||
d[Key.authors] = authorsArray
|
||||
}
|
||||
if let contentHash = contentHash {
|
||||
d[Key.contentHash] = contentHash
|
||||
}
|
||||
if unreadCount > 0 {
|
||||
d[Key.unreadCount] = unreadCount
|
||||
}
|
||||
if let conditionalGetInfo = conditionalGetInfo {
|
||||
d[Key.conditionalGetInfo] = conditionalGetInfo.dictionary
|
||||
}
|
||||
|
||||
return d
|
||||
var d = [String: Any]()
|
||||
|
||||
d[Key.url] = url
|
||||
|
||||
// feedID is not repeated when it’s the same as url
|
||||
if (feedID != url) {
|
||||
d[Key.feedID] = feedID
|
||||
}
|
||||
|
||||
if let homePageURL = homePageURL {
|
||||
d[Key.homePageURL] = homePageURL
|
||||
}
|
||||
if let iconURL = iconURL {
|
||||
d[Key.iconURL] = iconURL
|
||||
}
|
||||
if let faviconURL = faviconURL {
|
||||
d[Key.faviconURL] = faviconURL
|
||||
}
|
||||
if let name = name {
|
||||
d[Key.name] = name
|
||||
}
|
||||
if let editedName = editedName {
|
||||
d[Key.editedName] = editedName
|
||||
}
|
||||
if let authorsArray = authors?.diskArray() {
|
||||
d[Key.authors] = authorsArray
|
||||
}
|
||||
if let contentHash = contentHash {
|
||||
d[Key.contentHash] = contentHash
|
||||
}
|
||||
if unreadCount > 0 {
|
||||
d[Key.unreadCount] = unreadCount
|
||||
}
|
||||
if let conditionalGetInfo = conditionalGetInfo {
|
||||
d[Key.conditionalGetInfo] = conditionalGetInfo.dictionary
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
// MARK: - Debug
|
||||
|
@ -110,9 +110,7 @@ extension Article: DatabaseObject {
|
||||
}
|
||||
|
||||
public var databaseID: String {
|
||||
get {
|
||||
return articleID
|
||||
}
|
||||
return articleID
|
||||
}
|
||||
|
||||
public func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? {
|
||||
|
@ -26,9 +26,7 @@ extension ArticleStatus {
|
||||
extension ArticleStatus: DatabaseObject {
|
||||
|
||||
public var databaseID: String {
|
||||
get {
|
||||
return articleID
|
||||
}
|
||||
return articleID
|
||||
}
|
||||
|
||||
public func databaseDictionary() -> NSDictionary? {
|
||||
|
@ -57,9 +57,7 @@ private func optionalIntForColumn(_ row: FMResultSet, _ columnName: String) -> I
|
||||
extension Attachment: DatabaseObject {
|
||||
|
||||
public var databaseID: String {
|
||||
get {
|
||||
return attachmentID
|
||||
}
|
||||
return attachmentID
|
||||
}
|
||||
|
||||
public func databaseDictionary() -> NSDictionary? {
|
||||
|
@ -45,9 +45,7 @@ extension Author {
|
||||
extension Author: DatabaseObject {
|
||||
|
||||
public var databaseID: String {
|
||||
get {
|
||||
return authorID
|
||||
}
|
||||
return authorID
|
||||
}
|
||||
|
||||
public func databaseDictionary() -> NSDictionary? {
|
||||
|
@ -13,12 +13,10 @@ import Data
|
||||
extension ParsedItem {
|
||||
|
||||
var articleID: String {
|
||||
get {
|
||||
if let s = syncServiceID {
|
||||
return s
|
||||
}
|
||||
// Must be same calculation as for Article.
|
||||
return Article.calculatedArticleID(feedID: feedURL, uniqueID: uniqueID)
|
||||
if let s = syncServiceID {
|
||||
return s
|
||||
}
|
||||
// Must be same calculation as for Article.
|
||||
return Article.calculatedArticleID(feedID: feedURL, uniqueID: uniqueID)
|
||||
}
|
||||
}
|
||||
|
@ -179,9 +179,7 @@ private final class StatusCache {
|
||||
|
||||
var dictionary = [String: ArticleStatus]()
|
||||
var cachedStatuses: Set<ArticleStatus> {
|
||||
get {
|
||||
return Set(dictionary.values)
|
||||
}
|
||||
return Set(dictionary.values)
|
||||
}
|
||||
|
||||
func add(_ statuses: Set<ArticleStatus>) {
|
||||
|
@ -27,8 +27,6 @@ public struct UnreadCountDictionary {
|
||||
}
|
||||
|
||||
public subscript(_ feed: Feed) -> Int? {
|
||||
get {
|
||||
return dictionary[feed.feedID]
|
||||
}
|
||||
return dictionary[feed.feedID]
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,7 @@ public final class BatchUpdate {
|
||||
private var count = 0
|
||||
|
||||
public var isPerforming: Bool {
|
||||
get {
|
||||
return count > 0
|
||||
}
|
||||
return count > 0
|
||||
}
|
||||
|
||||
public func perform(_ batchUpdateBlock: BatchUpdateBlock) {
|
||||
|
@ -11,15 +11,12 @@ import AppKit
|
||||
public extension NSOutlineView {
|
||||
|
||||
var selectedItems: [AnyObject] {
|
||||
get {
|
||||
if selectionIsEmpty {
|
||||
return [AnyObject]()
|
||||
}
|
||||
|
||||
if selectionIsEmpty {
|
||||
return [AnyObject]()
|
||||
}
|
||||
|
||||
return selectedRowIndexes.compactMap { (oneIndex) -> AnyObject? in
|
||||
return item(atRow: oneIndex) as AnyObject
|
||||
}
|
||||
return selectedRowIndexes.compactMap { (oneIndex) -> AnyObject? in
|
||||
return item(atRow: oneIndex) as AnyObject
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,11 @@
|
||||
import AppKit
|
||||
|
||||
public extension NSTableView {
|
||||
|
||||
|
||||
var selectionIsEmpty: Bool {
|
||||
get {
|
||||
return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex
|
||||
}
|
||||
return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex
|
||||
}
|
||||
|
||||
|
||||
func indexesOfAvailableRowsPassingTest(_ test: (Int) -> Bool) -> IndexSet? {
|
||||
|
||||
// Checks visible and in-flight rows.
|
||||
|
@ -52,9 +52,7 @@ struct RelatedObjectIDsMap {
|
||||
}
|
||||
|
||||
subscript(_ objectID: String) -> Set<String>? {
|
||||
get {
|
||||
return dictionary[objectID]
|
||||
}
|
||||
return dictionary[objectID]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,6 @@ public struct RelatedObjectsMap {
|
||||
}
|
||||
|
||||
public subscript(_ objectID: String) -> [DatabaseObject]? {
|
||||
get {
|
||||
return dictionary[objectID]
|
||||
}
|
||||
return dictionary[objectID]
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ public struct FeedSpecifier: Hashable {
|
||||
public let source: Source
|
||||
public let hashValue: Int
|
||||
public var score: Int {
|
||||
get {
|
||||
return calculatedScore()
|
||||
}
|
||||
return calculatedScore()
|
||||
}
|
||||
|
||||
init(title: String?, urlString: String, source: Source) {
|
||||
|
@ -12,17 +12,15 @@ import RSParser
|
||||
private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"]
|
||||
|
||||
class HTMLFeedFinder {
|
||||
|
||||
|
||||
var feedSpecifiers: Set<FeedSpecifier> {
|
||||
get {
|
||||
return Set(feedSpecifiersDictionary.values)
|
||||
}
|
||||
return Set(feedSpecifiersDictionary.values)
|
||||
}
|
||||
|
||||
|
||||
fileprivate var feedSpecifiersDictionary = [String: FeedSpecifier]()
|
||||
|
||||
|
||||
init(parserData: ParserData) {
|
||||
|
||||
|
||||
let metadata = RSHTMLMetadataParser.htmlMetadata(with: parserData)
|
||||
|
||||
for oneFeedLink in metadata.feedLinks {
|
||||
|
@ -21,50 +21,40 @@ public final class Node: Hashable {
|
||||
private static var incrementingID = 0
|
||||
|
||||
public var isRoot: Bool {
|
||||
get {
|
||||
if let _ = parent {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
if let _ = parent {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public var numberOfChildNodes: Int {
|
||||
get {
|
||||
return childNodes?.count ?? 0
|
||||
}
|
||||
return childNodes?.count ?? 0
|
||||
}
|
||||
|
||||
public var indexPath: IndexPath {
|
||||
get {
|
||||
if let parent = parent {
|
||||
let parentPath = parent.indexPath
|
||||
if let childIndex = parent.indexOfChild(self) {
|
||||
return parentPath.appending(childIndex)
|
||||
}
|
||||
preconditionFailure("A Node’s parent must contain it as a child.")
|
||||
if let parent = parent {
|
||||
let parentPath = parent.indexPath
|
||||
if let childIndex = parent.indexOfChild(self) {
|
||||
return parentPath.appending(childIndex)
|
||||
}
|
||||
return IndexPath(index: 0) //root node
|
||||
preconditionFailure("A Node’s parent must contain it as a child.")
|
||||
}
|
||||
return IndexPath(index: 0) //root node
|
||||
}
|
||||
|
||||
public var level: Int {
|
||||
get {
|
||||
if let parent = parent {
|
||||
return parent.level + 1
|
||||
}
|
||||
return 0
|
||||
if let parent = parent {
|
||||
return parent.level + 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
public var isLeaf: Bool {
|
||||
get {
|
||||
return numberOfChildNodes < 1
|
||||
}
|
||||
return numberOfChildNodes < 1
|
||||
}
|
||||
|
||||
|
||||
public init(representedObject: AnyObject, parent: Node?) {
|
||||
|
||||
|
||||
precondition(Thread.isMainThread)
|
||||
|
||||
self.representedObject = representedObject
|
||||
|
@ -14,9 +14,7 @@ public final class DownloadObject: Hashable {
|
||||
public var data = Data()
|
||||
|
||||
public var hashValue: Int {
|
||||
get {
|
||||
return url.hashValue
|
||||
}
|
||||
return url.hashValue
|
||||
}
|
||||
|
||||
public init(url: URL) {
|
||||
|
@ -35,22 +35,18 @@ public final class DownloadProgress {
|
||||
}
|
||||
|
||||
public var numberCompleted: Int {
|
||||
get {
|
||||
var n = numberOfTasks - numberRemaining
|
||||
if n < 0 {
|
||||
n = 0
|
||||
}
|
||||
if n > numberOfTasks {
|
||||
n = numberOfTasks
|
||||
}
|
||||
return n
|
||||
var n = numberOfTasks - numberRemaining
|
||||
if n < 0 {
|
||||
n = 0
|
||||
}
|
||||
if n > numberOfTasks {
|
||||
n = numberOfTasks
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
public var isComplete: Bool {
|
||||
get {
|
||||
return numberRemaining < 1
|
||||
}
|
||||
return numberRemaining < 1
|
||||
}
|
||||
|
||||
public init(numberOfTasks: Int) {
|
||||
|
@ -294,9 +294,7 @@ private final class DownloadInfo {
|
||||
var canceled = false
|
||||
|
||||
var statusCode: Int {
|
||||
get {
|
||||
return urlResponse?.forcedStatusCode ?? 0
|
||||
}
|
||||
return urlResponse?.forcedStatusCode ?? 0
|
||||
}
|
||||
|
||||
init(_ representedObject: AnyObject, urlRequest: URLRequest) {
|
||||
|
@ -12,18 +12,16 @@ public struct HTTPConditionalGetInfo {
|
||||
|
||||
public let lastModified: String?
|
||||
public let etag: String?
|
||||
|
||||
|
||||
public var dictionary: [String: String] {
|
||||
get {
|
||||
var d = [String: String]()
|
||||
if let lastModified = lastModified {
|
||||
d[HTTPResponseHeader.lastModified] = lastModified
|
||||
}
|
||||
if let etag = etag {
|
||||
d[HTTPResponseHeader.etag] = etag
|
||||
}
|
||||
return d
|
||||
var d = [String: String]()
|
||||
if let lastModified = lastModified {
|
||||
d[HTTPResponseHeader.lastModified] = lastModified
|
||||
}
|
||||
if let etag = etag {
|
||||
d[HTTPResponseHeader.etag] = etag
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
public init?(lastModified: String?, etag: String?) {
|
||||
|
@ -9,23 +9,19 @@
|
||||
import Foundation
|
||||
|
||||
public extension URLResponse {
|
||||
|
||||
|
||||
public var statusIsOK: Bool {
|
||||
get {
|
||||
return forcedStatusCode >= 200 && forcedStatusCode <= 299
|
||||
}
|
||||
return forcedStatusCode >= 200 && forcedStatusCode <= 299
|
||||
}
|
||||
|
||||
|
||||
public var forcedStatusCode: Int {
|
||||
|
||||
get {
|
||||
// Return actual statusCode or -1 if there isn’t one.
|
||||
|
||||
if let response = self as? HTTPURLResponse {
|
||||
return response.statusCode
|
||||
}
|
||||
return 0
|
||||
|
||||
// Return actual statusCode or -1 if there isn’t one.
|
||||
|
||||
if let response = self as? HTTPURLResponse {
|
||||
return response.statusCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user