Make Feed provide a disk dictionary.

This commit is contained in:
Brent Simmons 2017-09-26 13:32:02 -07:00
parent 9b566dd10d
commit f187f6a9ef
2 changed files with 22 additions and 4 deletions

View File

@ -88,6 +88,27 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
get { get {
var d = [String: Any]() var d = [String: Any]()
d[Key.url] = url
d[Key.feedID] = feedID
if let homePageURL = homePageURL {
d[Key.homePageURL] = homePageURL
}
if let name = name {
d[Key.name] = name
}
if let editedName = editedName {
d[Key.editedName] = editedName
}
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 return d
} }
} }

View File

@ -36,11 +36,8 @@ public struct HTTPConditionalGetInfo {
self.init(lastModified: lastModified, etag: etag) self.init(lastModified: lastModified, etag: etag)
} }
public var dictionary: [String: String]? { public var dictionary: [String: String] {
get { get {
if lastModified == nil && etag == nil {
return nil
}
var d = [String: String]() var d = [String: String]()
if let lastModified = lastModified { if let lastModified = lastModified {
d[HTTPResponseHeader.lastModified] = lastModified d[HTTPResponseHeader.lastModified] = lastModified