Make ArticleStatus a reference type. Make article.status non-optional.
This commit is contained in:
parent
54ca352a70
commit
622fd51d50
|
@ -28,9 +28,10 @@ public struct Article: Hashable {
|
||||||
public let tags: Set<String>?
|
public let tags: Set<String>?
|
||||||
public let attachments: Set<Attachment>?
|
public let attachments: Set<Attachment>?
|
||||||
public let accountInfo: AccountInfo?
|
public let accountInfo: AccountInfo?
|
||||||
|
public let status: ArticleStatus
|
||||||
public let hashValue: Int
|
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.accountID = accountID
|
||||||
self.feedID = feedID
|
self.feedID = feedID
|
||||||
|
@ -49,7 +50,8 @@ public struct Article: Hashable {
|
||||||
self.tags = tags
|
self.tags = tags
|
||||||
self.attachments = attachments
|
self.attachments = attachments
|
||||||
self.accountInfo = accountInfo
|
self.accountInfo = accountInfo
|
||||||
|
self.status = status
|
||||||
|
|
||||||
if let articleID = articleID {
|
if let articleID = articleID {
|
||||||
self.articleID = articleID
|
self.articleID = articleID
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
// Threading rules:
|
||||||
|
// * Main-thread only
|
||||||
|
// * Except: may be created on background thread by StatusesTable.
|
||||||
|
// Which is safe, because at creation time it’t not yet shared,
|
||||||
|
// and it won’t be mutated ever on a background thread.
|
||||||
|
|
||||||
public enum ArticleStatusKey: String {
|
public enum ArticleStatusKey: String {
|
||||||
|
|
||||||
case read = "read"
|
case read = "read"
|
||||||
|
@ -15,7 +21,7 @@ public enum ArticleStatusKey: String {
|
||||||
case userDeleted = "userDeleted"
|
case userDeleted = "userDeleted"
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ArticleStatus: Hashable {
|
public final class ArticleStatus: Hashable {
|
||||||
|
|
||||||
public let articleID: String
|
public let articleID: String
|
||||||
public let dateArrived: Date
|
public let dateArrived: Date
|
||||||
|
@ -60,7 +66,7 @@ public struct ArticleStatus: Hashable {
|
||||||
return false
|
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) {
|
if let articleStatusKey = ArticleStatusKey(rawValue: key) {
|
||||||
switch articleStatusKey {
|
switch articleStatusKey {
|
||||||
|
|
Loading…
Reference in New Issue