2017-10-07 21:41:21 -07:00
|
|
|
//
|
|
|
|
// DataExtensions.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 10/7/17.
|
|
|
|
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2018-07-23 18:29:08 -07:00
|
|
|
import Articles
|
2017-11-25 12:17:49 -08:00
|
|
|
import RSParser
|
2017-10-07 21:41:21 -07:00
|
|
|
|
2017-11-25 13:48:14 -08:00
|
|
|
public extension Notification.Name {
|
2019-02-12 10:04:18 -05:00
|
|
|
static let FeedSettingDidChange = Notification.Name(rawValue: "FeedSettingDidChangeNotification")
|
2017-11-25 13:48:14 -08:00
|
|
|
}
|
|
|
|
|
2017-10-07 21:41:21 -07:00
|
|
|
public extension Feed {
|
|
|
|
|
2019-03-31 16:12:17 -07:00
|
|
|
static let FeedSettingUserInfoKey = "feedSetting"
|
2019-03-17 12:47:04 -07:00
|
|
|
|
2019-03-31 16:12:17 -07:00
|
|
|
struct FeedSettingKey {
|
2019-03-17 13:54:30 -07:00
|
|
|
public static let homePageURL = "homePageURL"
|
|
|
|
public static let iconURL = "iconURL"
|
|
|
|
public static let faviconURL = "faviconURL"
|
|
|
|
public static let name = "name"
|
|
|
|
public static let editedName = "editedName"
|
|
|
|
public static let authors = "authors"
|
|
|
|
public static let contentHash = "contentHash"
|
|
|
|
public static let conditionalGetInfo = "conditionalGetInfo"
|
2019-03-17 12:47:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Feed {
|
|
|
|
|
2019-02-12 10:04:18 -05:00
|
|
|
func takeSettings(from parsedFeed: ParsedFeed) {
|
2019-03-17 12:47:04 -07:00
|
|
|
iconURL = parsedFeed.iconURL
|
|
|
|
faviconURL = parsedFeed.faviconURL
|
|
|
|
homePageURL = parsedFeed.homePageURL
|
|
|
|
name = parsedFeed.title
|
|
|
|
authors = Author.authorsWithParsedAuthors(parsedFeed.authors)
|
|
|
|
}
|
2017-11-25 12:17:49 -08:00
|
|
|
|
2019-03-17 12:47:04 -07:00
|
|
|
func postFeedSettingDidChangeNotification(_ codingKey: FeedMetadata.CodingKeys) {
|
|
|
|
let userInfo = [Feed.FeedSettingUserInfoKey: codingKey.stringValue]
|
|
|
|
NotificationCenter.default.post(name: .FeedSettingDidChange, object: self, userInfo: userInfo)
|
2017-11-25 12:17:49 -08:00
|
|
|
}
|
2017-10-07 21:41:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public extension Article {
|
|
|
|
|
2019-02-12 10:04:18 -05:00
|
|
|
var account: Account? {
|
2018-02-14 13:14:25 -08:00
|
|
|
return AccountManager.shared.existingAccount(with: accountID)
|
2017-10-07 21:41:21 -07:00
|
|
|
}
|
2017-10-08 22:25:33 -07:00
|
|
|
|
2019-02-12 10:04:18 -05:00
|
|
|
var feed: Feed? {
|
2018-02-14 13:14:25 -08:00
|
|
|
return account?.existingFeed(with: feedID)
|
2017-10-08 22:25:33 -07:00
|
|
|
}
|
2017-10-07 21:41:21 -07:00
|
|
|
}
|
2017-10-10 13:23:12 -07:00
|
|
|
|