diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 6ea96551d..35818a012 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -837,14 +837,7 @@ private extension FeedbinAccountDelegate { os_log(.debug, log: log, "Syncing taggings with %ld taggings.", taggings.count) // Set up some structures to make syncing easier - let folderDict: [String: Folder] = { - if let folders = account.folders { - return Dictionary(uniqueKeysWithValues: folders.map { ($0.name ?? "", $0) } ) - } else { - return [String: Folder]() - } - }() - + let folderDict = nameToFolderDictionary(with: account.folders) let taggingsDict = taggings.reduce([String: [FeedbinTagging]]()) { (dict, tagging) in var taggedFeeds = dict if var taggedFeed = taggedFeeds[tagging.name] { @@ -897,7 +890,22 @@ private extension FeedbinAccountDelegate { } } } - + + func nameToFolderDictionary(with folders: Set?) -> [String: Folder] { + guard let folders = folders else { + return [String: Folder]() + } + + var d = [String: Folder]() + for folder in folders { + let name = folder.name ?? "" + if d[name] == nil { + d[name] = folder + } + } + return d + } + func sendArticleStatuses(_ statuses: [SyncStatus], apiCall: ([Int], @escaping (Result) -> Void) -> Void, completion: @escaping ((Result) -> Void)) { diff --git a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index fc3c891dd..ad55d4e6c 100644 --- a/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Frameworks/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -598,14 +598,7 @@ private extension ReaderAPIAccountDelegate { os_log(.debug, log: log, "Syncing taggings with %ld subscriptions.", subscriptions.count) // Set up some structures to make syncing easier - let folderDict: [String: Folder] = { - if let folders = account.folders { - return Dictionary(uniqueKeysWithValues: folders.map { ($0.name ?? "", $0) } ) - } else { - return [String: Folder]() - } - }() - + let folderDict = nameToFolderDictionary(with: account.folders) let taggingsDict = subscriptions.reduce([String: [ReaderAPISubscription]]()) { (dict, subscription) in var taggedFeeds = dict @@ -667,6 +660,21 @@ private extension ReaderAPIAccountDelegate { } + func nameToFolderDictionary(with folders: Set?) -> [String: Folder] { + guard let folders = folders else { + return [String: Folder]() + } + + var d = [String: Folder]() + for folder in folders { + let name = folder.name ?? "" + if d[name] == nil { + d[name] = folder + } + } + return d + } + func sendArticleStatuses(_ statuses: [SyncStatus], apiCall: ([Int], @escaping (Result) -> Void) -> Void, completion: @escaping (() -> Void)) {