#1718 (nested folder bug)

- Fixed duplication of feeds from subfolders.
This commit is contained in:
David Sinclair 2022-11-30 15:08:30 -06:00
parent 9adbe4c479
commit 031ddba2c4

View file

@ -65,19 +65,25 @@ class FeedsViewController: FeedsObjCViewController {
return
}
guard let childFeeds = appDelegate.dictFolders[folderTitle] as? [AnyObject],
let parentFeeds = appDelegate.dictFolders[parentTitle] as? [AnyObject] else {
guard let childFeeds = appDelegate.dictFolders[folderTitle] as? [AnyHashable],
let parentFeeds = appDelegate.dictFolders[parentTitle] as? [AnyHashable] else {
return
}
let existingSubfolders = appDelegate.dictSubfolders[parentTitle] as? [AnyObject] ?? []
let existingSubfolders = appDelegate.dictSubfolders[parentTitle] as? [AnyHashable] ?? []
appDelegate.dictFolders[parentTitle] = parentFeeds + childFeeds
appDelegate.dictSubfolders[parentTitle] = existingSubfolders + childFeeds
appDelegate.dictFolders[parentTitle] = unique(parentFeeds + childFeeds)
appDelegate.dictSubfolders[parentTitle] = unique(existingSubfolders + childFeeds)
addSubfolderFeeds(for: parentTitle)
}
private func unique(_ array: [AnyHashable]) -> [AnyHashable] {
var seen: Set<AnyHashable> = []
return array.filter { seen.insert($0).inserted }
}
@objc(parentTitleForFolderTitle:) func parentTitle(for folderTitle: String) -> String? {
guard let range = folderTitle.range(of: "", options: .backwards) else {
return nil