2017-10-08 06:41:21 +02:00
|
|
|
//
|
|
|
|
// DataExtensions.swift
|
2019-07-09 07:58:19 +02:00
|
|
|
// NetNewsWire
|
2017-10-08 06:41:21 +02:00
|
|
|
//
|
|
|
|
// 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-11-15 03:11:41 +01:00
|
|
|
static let WebFeedSettingDidChange = Notification.Name(rawValue: "FeedSettingDidChangeNotification")
|
2017-11-25 22:48:14 +01:00
|
|
|
}
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
public extension WebFeed {
|
2017-10-08 06:41:21 +02:00
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
static let WebFeedSettingUserInfoKey = "feedSetting"
|
2019-03-17 20:47:04 +01:00
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
struct WebFeedSettingKey {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
extension WebFeed {
|
2019-03-17 20:47:04 +01:00
|
|
|
|
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-11-15 03:11:41 +01:00
|
|
|
func postFeedSettingDidChangeNotification(_ codingKey: WebFeedMetadata.CodingKeys) {
|
|
|
|
let userInfo = [WebFeed.WebFeedSettingUserInfoKey: codingKey.stringValue]
|
|
|
|
NotificationCenter.default.post(name: .WebFeedSettingDidChange, 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? {
|
2019-10-03 05:30:43 +02:00
|
|
|
// The force unwrapped shared instance was crashing Account.framework unit tests.
|
|
|
|
guard let manager = AccountManager.shared else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return manager.existingAccount(with: accountID)
|
2017-10-08 06:41:21 +02:00
|
|
|
}
|
2017-10-09 07:25:33 +02:00
|
|
|
|
2019-11-15 03:11:41 +01:00
|
|
|
var webFeed: WebFeed? {
|
|
|
|
return account?.existingWebFeed(withWebFeedID: webFeedID)
|
2017-10-09 07:25:33 +02:00
|
|
|
}
|
2017-10-08 06:41:21 +02:00
|
|
|
}
|
2017-10-10 22:23:12 +02:00
|
|
|
|