mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix feeds being returned without corresponding folder
This commit is contained in:
@@ -80,13 +80,13 @@ extension NewsBlurAccountDelegate {
|
||||
|
||||
os_log(.debug, log: log, "Syncing feeds with %ld feeds.", feeds.count)
|
||||
|
||||
let subFeedIds = feeds.map { String($0.feedID) }
|
||||
let newsBlurFeedIds = feeds.map { String($0.feedID) }
|
||||
|
||||
// Remove any feeds that are no longer in the subscriptions
|
||||
if let folders = account.folders {
|
||||
for folder in folders {
|
||||
for feed in folder.topLevelWebFeeds {
|
||||
if !subFeedIds.contains(feed.webFeedID) {
|
||||
if !newsBlurFeedIds.contains(feed.webFeedID) {
|
||||
folder.removeWebFeed(feed)
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ extension NewsBlurAccountDelegate {
|
||||
}
|
||||
|
||||
for feed in account.topLevelWebFeeds {
|
||||
if !subFeedIds.contains(feed.webFeedID) {
|
||||
if !newsBlurFeedIds.contains(feed.webFeedID) {
|
||||
account.removeWebFeed(feed)
|
||||
}
|
||||
}
|
||||
@@ -491,7 +491,7 @@ extension NewsBlurAccountDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
if account.flattenedWebFeeds().first(where: { $0.webFeedID == feedID }) == nil {
|
||||
if account.existingWebFeed(withWebFeedID: feedID) != nil {
|
||||
account.clearWebFeedMetadata(feed)
|
||||
}
|
||||
|
||||
|
||||
@@ -59,26 +59,31 @@ extension NewsBlurFeedsResponse {
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
// Parse feeds
|
||||
var feeds: [NewsBlurFeed] = []
|
||||
let feedContainer = try container.nestedContainer(keyedBy: NewsBlurGenericCodingKeys.self, forKey: .feeds)
|
||||
try feedContainer.allKeys.forEach { key in
|
||||
let subscription = try feedContainer.decode(NewsBlurFeed.self, forKey: key)
|
||||
feeds.append(subscription)
|
||||
}
|
||||
// Tricky part: Some feeds listed in `feeds` don't exist in `folders` for some reason
|
||||
// They don't show up on both mobile/web app, so let's filter them out
|
||||
var visibleFeedIDs: [Int] = []
|
||||
|
||||
// Parse folders
|
||||
var folders: [Folder] = []
|
||||
let folderContainer = try container.nestedContainer(keyedBy: NewsBlurGenericCodingKeys.self, forKey: .folders)
|
||||
|
||||
for key in folderContainer.allKeys {
|
||||
let subscriptionIds = try folderContainer.decode([Int].self, forKey: key)
|
||||
let folder = Folder(name: key.stringValue, feedIDs: subscriptionIds)
|
||||
let feedIDs = try folderContainer.decode([Int].self, forKey: key)
|
||||
let folder = Folder(name: key.stringValue, feedIDs: feedIDs)
|
||||
|
||||
folders.append(folder)
|
||||
visibleFeedIDs.append(contentsOf: feedIDs)
|
||||
}
|
||||
|
||||
self.feeds = feeds
|
||||
// Parse feeds
|
||||
var feeds: [NewsBlurFeed] = []
|
||||
let feedContainer = try container.nestedContainer(keyedBy: NewsBlurGenericCodingKeys.self, forKey: .feeds)
|
||||
try feedContainer.allKeys.forEach { key in
|
||||
let feed = try feedContainer.decode(NewsBlurFeed.self, forKey: key)
|
||||
feeds.append(feed)
|
||||
}
|
||||
|
||||
self.feeds = feeds.filter { visibleFeedIDs.contains($0.feedID) }
|
||||
self.folders = folders
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user