2019-03-13 06:40:11 +01:00
|
|
|
//
|
|
|
|
// FeedMetadata.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 3/12/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSWeb
|
|
|
|
import Articles
|
|
|
|
|
|
|
|
protocol FeedMetadataDelegate: class {
|
|
|
|
func valueDidChange(_ feedMetadata: FeedMetadata, key: FeedMetadata.CodingKeys)
|
|
|
|
}
|
|
|
|
|
2019-03-17 00:39:16 +01:00
|
|
|
final class FeedMetadata: Codable {
|
2019-03-13 06:40:11 +01:00
|
|
|
|
|
|
|
let feedID: String
|
|
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case feedID
|
|
|
|
case homePageURL
|
|
|
|
case iconURL
|
|
|
|
case faviconURL
|
|
|
|
case name
|
|
|
|
case editedName
|
|
|
|
case authors
|
|
|
|
case contentHash
|
|
|
|
case conditionalGetInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
var homePageURL: String? {
|
|
|
|
didSet {
|
|
|
|
if homePageURL != oldValue {
|
|
|
|
valueDidChange(.homePageURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var iconURL: String? {
|
|
|
|
didSet {
|
|
|
|
if iconURL != oldValue {
|
|
|
|
valueDidChange(.iconURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var faviconURL: String? {
|
|
|
|
didSet {
|
|
|
|
if faviconURL != oldValue {
|
|
|
|
valueDidChange(.faviconURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var name: String? {
|
|
|
|
didSet {
|
|
|
|
if name != oldValue {
|
|
|
|
valueDidChange(.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var editedName: String? {
|
|
|
|
didSet {
|
|
|
|
if editedName != oldValue {
|
|
|
|
valueDidChange(.editedName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var contentHash: String? {
|
|
|
|
didSet {
|
|
|
|
if contentHash != oldValue {
|
|
|
|
valueDidChange(.contentHash)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var authors: [Author]? {
|
|
|
|
didSet {
|
|
|
|
if authors != oldValue {
|
|
|
|
valueDidChange(.authors)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var conditionalGetInfo: HTTPConditionalGetInfo? {
|
|
|
|
didSet {
|
|
|
|
if conditionalGetInfo != oldValue {
|
|
|
|
valueDidChange(.conditionalGetInfo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
weak var delegate: FeedMetadataDelegate?
|
|
|
|
|
2019-03-14 07:41:43 +01:00
|
|
|
init(feedID: String) {
|
2019-03-13 06:40:11 +01:00
|
|
|
self.feedID = feedID
|
|
|
|
}
|
|
|
|
|
|
|
|
func valueDidChange(_ key: CodingKeys) {
|
|
|
|
delegate?.valueDidChange(self, key: key)
|
|
|
|
}
|
|
|
|
}
|