Update a Feed with settings taken from the raw feed. (Some Feeds had no homePageURL set, which meant, in most cases, no favicons.)

This commit is contained in:
Brent Simmons 2017-11-25 12:17:49 -08:00
parent 09c5d09c4e
commit 55166e0979
2 changed files with 28 additions and 6 deletions

View File

@ -150,12 +150,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
func update(_ feed: Feed, with parsedFeed: ParsedFeed, _ completion: @escaping RSVoidCompletionBlock) {
if feed.iconURL != parsedFeed.iconURL {
feed.iconURL = parsedFeed.iconURL
dirty = true
}
if feed.faviconURL != parsedFeed.faviconURL {
feed.faviconURL = parsedFeed.faviconURL
if feed.takeSettings(from: parsedFeed) {
dirty = true
}

View File

@ -8,6 +8,7 @@
import Foundation
import Data
import RSParser
public extension Feed {
@ -25,6 +26,32 @@ public extension Feed {
}
return account.fetchArticles(for: self)
}
public func takeSettings(from parsedFeed: ParsedFeed) -> Bool {
// Return true if anything changed.
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
}
return didChangeAtLeastOneSetting
}
}
public extension Article {