Make ArticleStatus a reference type. Make article.status non-optional.

This commit is contained in:
Brent Simmons 2017-09-18 12:59:42 -07:00
parent 54ca352a70
commit 622fd51d50
2 changed files with 12 additions and 4 deletions

View File

@ -28,9 +28,10 @@ public struct Article: Hashable {
public let tags: Set<String>?
public let attachments: Set<Attachment>?
public let accountInfo: AccountInfo?
public let status: ArticleStatus
public let hashValue: Int
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, tags: Set<String>?, attachments: Set<Attachment>?, accountInfo: AccountInfo?) {
public init(accountID: String, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: Set<Author>?, tags: Set<String>?, attachments: Set<Attachment>?, accountInfo: AccountInfo?, status: ArticleStatus) {
self.accountID = accountID
self.feedID = feedID
@ -49,7 +50,8 @@ public struct Article: Hashable {
self.tags = tags
self.attachments = attachments
self.accountInfo = accountInfo
self.status = status
if let articleID = articleID {
self.articleID = articleID
}

View File

@ -8,6 +8,12 @@
import Foundation
// Threading rules:
// * Main-thread only
// * Except: may be created on background thread by StatusesTable.
// Which is safe, because at creation time itt not yet shared,
// and it wont be mutated ever on a background thread.
public enum ArticleStatusKey: String {
case read = "read"
@ -15,7 +21,7 @@ public enum ArticleStatusKey: String {
case userDeleted = "userDeleted"
}
public struct ArticleStatus: Hashable {
public final class ArticleStatus: Hashable {
public let articleID: String
public let dateArrived: Date
@ -60,7 +66,7 @@ public struct ArticleStatus: Hashable {
return false
}
public mutating func setBoolStatus(_ status: Bool, forKey key: String) {
public func setBoolStatus(_ status: Bool, forKey key: String) {
if let articleStatusKey = ArticleStatusKey(rawValue: key) {
switch articleStatusKey {