2017-07-02 02:22:19 +02:00
|
|
|
//
|
|
|
|
// Feed.swift
|
|
|
|
// DataModel
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 7/1/17.
|
|
|
|
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSCore
|
|
|
|
|
2017-09-08 06:00:30 +02:00
|
|
|
public final class Feed: DisplayNameProvider, Hashable {
|
2017-07-02 02:22:19 +02:00
|
|
|
|
2017-09-08 05:51:51 +02:00
|
|
|
public let accountID: String
|
2017-07-02 02:22:19 +02:00
|
|
|
public let url: String
|
|
|
|
public let feedID: String
|
|
|
|
public var homePageURL: String?
|
|
|
|
public var name: String?
|
|
|
|
public var editedName: String?
|
2017-07-03 19:29:44 +02:00
|
|
|
public var articles = Set<Article>()
|
2017-09-10 03:46:58 +02:00
|
|
|
public var accountInfo: AccountInfo? //If account needs to store more data
|
2017-07-03 19:29:44 +02:00
|
|
|
public let hashValue: Int
|
|
|
|
|
2017-07-02 02:22:19 +02:00
|
|
|
public var nameForDisplay: String {
|
|
|
|
get {
|
|
|
|
return (editedName ?? name) ?? NSLocalizedString("Untitled", comment: "Feed name")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-08 06:00:30 +02:00
|
|
|
// public var unreadCount = 0 {
|
|
|
|
// didSet {
|
|
|
|
// if unreadCount != oldValue {
|
|
|
|
// postUnreadCountDidChangeNotification()
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2017-07-03 19:29:44 +02:00
|
|
|
|
2017-09-08 05:51:51 +02:00
|
|
|
public init(accountID: String, url: String, feedID: String) {
|
2017-07-02 02:22:19 +02:00
|
|
|
|
2017-09-08 05:51:51 +02:00
|
|
|
self.accountID = accountID
|
2017-07-02 02:22:19 +02:00
|
|
|
self.url = url
|
|
|
|
self.feedID = feedID
|
2017-09-08 05:51:51 +02:00
|
|
|
self.hashValue = accountID.hashValue ^ url.hashValue ^ feedID.hashValue
|
2017-07-02 02:22:19 +02:00
|
|
|
}
|
|
|
|
|
2017-09-08 06:00:30 +02:00
|
|
|
// public func updateUnreadCount() {
|
|
|
|
//
|
|
|
|
// unreadCount = articles.reduce(0) { (result, oneArticle) -> Int in
|
|
|
|
// if let read = oneArticle.status?.read, !read {
|
|
|
|
// return result + 1
|
|
|
|
// }
|
|
|
|
// return result
|
|
|
|
// }
|
|
|
|
// }
|
2017-07-02 02:22:19 +02:00
|
|
|
|
|
|
|
public class func ==(lhs: Feed, rhs: Feed) -> Bool {
|
|
|
|
|
|
|
|
return lhs === rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|