Fix folder renaming issue that occurs for Feedbin when the tag doesn't exist at Feedbin. Issue #724
This commit is contained in:
parent
8bd9cef7be
commit
f4e0cfaf2b
|
@ -243,10 +243,16 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
|||
|
||||
func renameFolder(for account: Account, with folder: Folder, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
guard folder.hasAtLeastOneFeed() else {
|
||||
folder.name = name
|
||||
return
|
||||
}
|
||||
|
||||
caller.renameTag(oldName: folder.name ?? "", newName: name) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
DispatchQueue.main.async {
|
||||
self.renameFolderRelationship(for: account, fromName: folder.name ?? "", toName: name)
|
||||
folder.name = name
|
||||
completion(.success(()))
|
||||
}
|
||||
|
@ -840,6 +846,17 @@ private extension FeedbinAccountDelegate {
|
|||
|
||||
}
|
||||
|
||||
func renameFolderRelationship(for account: Account, fromName: String, toName: String) {
|
||||
for feed in account.flattenedFeeds() {
|
||||
if var folderRelationship = feed.folderRelationship {
|
||||
let relationship = folderRelationship[fromName]
|
||||
folderRelationship[fromName] = nil
|
||||
folderRelationship[toName] = relationship
|
||||
feed.folderRelationship = folderRelationship
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func clearFolderRelationship(for feed: Feed, withFolderName folderName: String) {
|
||||
if var folderRelationship = feed.folderRelationship {
|
||||
folderRelationship[folderName] = nil
|
||||
|
|
Loading…
Reference in New Issue