NetNewsWire/Frameworks/Account/FeedMetadata.swift

141 lines
2.4 KiB
Swift

//
// FeedMetadata.swift
// NetNewsWire
//
// 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)
}
final class FeedMetadata: Codable {
enum CodingKeys: String, CodingKey {
case feedID
case homePageURL
case iconURL
case faviconURL
case editedName
case authors
case contentHash
case isNotifyAboutNewArticles
case isArticleExtractorAlwaysOn
case conditionalGetInfo
case subscriptionID
case folderRelationship
}
var feedID: String {
didSet {
if feedID != oldValue {
valueDidChange(.feedID)
}
}
}
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 editedName: String? {
didSet {
if editedName != oldValue {
valueDidChange(.editedName)
}
}
}
var contentHash: String? {
didSet {
if contentHash != oldValue {
valueDidChange(.contentHash)
}
}
}
var isNotifyAboutNewArticles: Bool? {
didSet {
if isNotifyAboutNewArticles != oldValue {
valueDidChange(.isNotifyAboutNewArticles)
}
}
}
var isArticleExtractorAlwaysOn: Bool? {
didSet {
if isArticleExtractorAlwaysOn != oldValue {
valueDidChange(.isArticleExtractorAlwaysOn)
}
}
}
var authors: [Author]? {
didSet {
if authors != oldValue {
valueDidChange(.authors)
}
}
}
var conditionalGetInfo: HTTPConditionalGetInfo? {
didSet {
if conditionalGetInfo != oldValue {
valueDidChange(.conditionalGetInfo)
}
}
}
var subscriptionID: String? {
didSet {
if subscriptionID != oldValue {
valueDidChange(.subscriptionID)
}
}
}
// Folder Name: Sync Service Relationship ID
var folderRelationship: [String: String]? {
didSet {
if folderRelationship != oldValue {
valueDidChange(.folderRelationship)
}
}
}
weak var delegate: FeedMetadataDelegate?
init(feedID: String) {
self.feedID = feedID
}
func valueDidChange(_ key: CodingKeys) {
delegate?.valueDidChange(self, key: key)
}
}