Fix duplicate folder relationships caused by OPMLNormalizer
This commit is contained in:
parent
b38f720a62
commit
6bd2c0dc06
|
@ -202,22 +202,7 @@ final class CloudKitAccountDelegate: AccountDelegate {
|
|||
|
||||
let normalizedItems = OPMLNormalizer.normalize(opmlItems)
|
||||
|
||||
// Combine all existing web feed URLs with all the new ones
|
||||
|
||||
var webFeedURLs = account.flattenedWebFeedURLs
|
||||
for opmlItem in normalizedItems {
|
||||
if let webFeedURL = opmlItem.feedSpecifier?.feedURL {
|
||||
webFeedURLs.insert(webFeedURL)
|
||||
} else {
|
||||
if let childItems = opmlItem.children {
|
||||
for childItem in childItems {
|
||||
if let webFeedURL = childItem.feedSpecifier?.feedURL {
|
||||
webFeedURLs.insert(webFeedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: remove duplicates created by import
|
||||
|
||||
self.accountZone.importOPML(rootExternalID: rootExternalID, items: normalizedItems) { _ in
|
||||
self.refreshAll(for: account, downloadFeeds: false, completion: completion)
|
||||
|
|
|
@ -23,7 +23,6 @@ final class OPMLNormalizer {
|
|||
var feedsToAdd = [RSOPMLItem]()
|
||||
|
||||
items.forEach { (item) in
|
||||
|
||||
if let _ = item.feedSpecifier {
|
||||
if !feedsToAdd.contains(where: { $0.feedSpecifier?.feedURL == item.feedSpecifier?.feedURL }) {
|
||||
feedsToAdd.append(item)
|
||||
|
@ -39,16 +38,15 @@ final class OPMLNormalizer {
|
|||
return
|
||||
}
|
||||
|
||||
normalizedOPMLItems.append(item)
|
||||
if let itemChildren = item.children {
|
||||
normalize(itemChildren, parentFolder: item)
|
||||
}
|
||||
feedsToAdd.append(item)
|
||||
}
|
||||
|
||||
if let parentFolder = parentFolder {
|
||||
for feed in feedsToAdd {
|
||||
if !(parentFolder.children?.contains(where: { $0.feedSpecifier?.feedURL == feed.feedSpecifier?.feedURL}) ?? false) {
|
||||
parentFolder.addChild(feed)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for feed in feedsToAdd {
|
||||
normalizedOPMLItems.append(feed)
|
||||
|
|
Loading…
Reference in New Issue