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