mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Replace use of Dictionary(uniqueKeysWithValues) with a separate function that can handle duplicate keys without crashing. Fix #1671.
This commit is contained in:
parent
eb3b3e5955
commit
61ccf6fa1f
@ -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<Folder>?) -> [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, Error>) -> Void) -> Void,
|
||||
completion: @escaping ((Result<Void, Error>) -> Void)) {
|
||||
|
@ -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<Folder>?) -> [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, Error>) -> Void) -> Void,
|
||||
completion: @escaping (() -> Void)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user