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
|
|
|
|
import Data
|
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 {
|
|
|
|
|
|
|
|
public static let FeedSettingDidChange = Notification.Name(rawValue: "FeedSettingDidChangeNotification")
|
|
|
|
}
|
|
|
|
|
2017-10-08 06:41:21 +02:00
|
|
|
public extension Feed {
|
|
|
|
|
2017-10-09 03:58:15 +02:00
|
|
|
public 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 03:58:15 +02:00
|
|
|
|
2017-11-25 22:48:14 +01:00
|
|
|
public func takeSettings(from parsedFeed: ParsedFeed) {
|
2017-11-25 21:17:49 +01:00
|
|
|
|
|
|
|
var didChangeAtLeastOneSetting = false
|
|
|
|
|
|
|
|
if iconURL != parsedFeed.iconURL {
|
|
|
|
iconURL = parsedFeed.iconURL
|
|
|
|
didChangeAtLeastOneSetting = true
|
|
|
|
}
|
|
|
|
if faviconURL != parsedFeed.faviconURL {
|
|
|
|
faviconURL = parsedFeed.faviconURL
|
|
|
|
didChangeAtLeastOneSetting = true
|
|
|
|
}
|
|
|
|
if homePageURL != parsedFeed.homePageURL {
|
|
|
|
homePageURL = parsedFeed.homePageURL
|
|
|
|
didChangeAtLeastOneSetting = true
|
|
|
|
}
|
|
|
|
if name != parsedFeed.title {
|
|
|
|
name = parsedFeed.title
|
|
|
|
didChangeAtLeastOneSetting = true
|
|
|
|
}
|
|
|
|
|
2017-12-02 23:20:58 +01:00
|
|
|
let updatedAuthors = Author.authorsWithParsedAuthors(parsedFeed.authors)
|
|
|
|
if authors != updatedAuthors {
|
|
|
|
authors = updatedAuthors
|
|
|
|
didChangeAtLeastOneSetting = true
|
|
|
|
}
|
|
|
|
|
2017-11-25 22:48:14 +01:00
|
|
|
if didChangeAtLeastOneSetting {
|
|
|
|
NotificationCenter.default.post(name: .FeedSettingDidChange, object: self)
|
|
|
|
}
|
2017-11-25 21:17:49 +01:00
|
|
|
}
|
2017-10-08 06:41:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public extension Article {
|
|
|
|
|
2017-10-09 07:25:33 +02:00
|
|
|
public 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
|
|
|
|
|
|
|
public 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
|
|
|
|