From 31cc3b609c4de36a2afac0259825478edd1a7d0d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 20 May 2019 18:05:28 -0500 Subject: [PATCH] Make delete animation correct for deletes and restores by wrapping them in BatchUpdates. Issue #667 --- .../Account/Feedbin/FeedbinAccountDelegate.swift | 16 ++++++++-------- Shared/Commands/DeleteCommand.swift | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 0149d2d58..091666b8c 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -837,18 +837,14 @@ private extension FeedbinAccountDelegate { if editedName != nil { DispatchQueue.main.async { - BatchUpdate.shared.perform { - account.removeFeed(feed) - folder.addFeed(feed) - } + account.removeFeed(feed) + folder.addFeed(feed) } self?.processRestoredFeedName(for: account, feed: feed, editedName: editedName!, completion: completion) } else { DispatchQueue.main.async { - BatchUpdate.shared.perform { - account.removeFeed(feed) - folder.addFeed(feed) - } + account.removeFeed(feed) + folder.addFeed(feed) completion(.success(())) } } @@ -869,6 +865,10 @@ private extension FeedbinAccountDelegate { if editedName != nil { processRestoredFeedName(for: account, feed: feed, editedName: editedName!, completion: completion) + } else { + DispatchQueue.main.async { + completion(.success(())) + } } } diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index bf38155d7..afd07f1f2 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -135,11 +135,15 @@ private struct SidebarItemSpecifier { func delete() { if let feed = feed { + BatchUpdate.shared.start() account?.deleteFeed(feed) { result in + BatchUpdate.shared.end() self.checkResult(result) } } else if let folder = folder { + BatchUpdate.shared.start() account?.deleteFolder(folder) { result in + BatchUpdate.shared.end() self.checkResult(result) } } @@ -161,7 +165,9 @@ private struct SidebarItemSpecifier { return } + BatchUpdate.shared.start() account.restoreFeed(feed, folder: resolvedFolder()) { result in + BatchUpdate.shared.end() self.checkResult(result) } @@ -173,7 +179,9 @@ private struct SidebarItemSpecifier { return } + BatchUpdate.shared.start() account.restoreFolder(folder) { result in + BatchUpdate.shared.end() self.checkResult(result) }