Use BatchUpdate.shared.

This commit is contained in:
Brent Simmons 2017-10-05 20:38:54 -07:00
parent c258a9da5c
commit 0f19fda54d
5 changed files with 6 additions and 5 deletions

View File

@ -16,7 +16,6 @@ import Account
let appName = "Evergreen" let appName = "Evergreen"
var currentTheme: VSTheme! var currentTheme: VSTheme!
let batchUpdate = BatchUpdate()
@NSApplicationMain @NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {

View File

@ -17,6 +17,8 @@ public extension Notification.Name {
final class BatchUpdate { final class BatchUpdate {
static let shared = BatchUpdate()
private var count = 0 private var count = 0
var isPerforming: Bool { var isPerforming: Bool {

View File

@ -73,7 +73,7 @@ import Account
outlineView.removeItems(at: selectedRows, inParent: nil, withAnimation: [.slideDown]) outlineView.removeItems(at: selectedRows, inParent: nil, withAnimation: [.slideDown])
outlineView.endUpdates() outlineView.endUpdates()
batchUpdate.perform { BatchUpdate.shared.perform {
deleteItemsForNodes(nodesToDelete) deleteItemsForNodes(nodesToDelete)
} }
@ -164,7 +164,7 @@ private extension SidebarViewController {
func rebuildTreeAndReloadDataIfNeeded() { func rebuildTreeAndReloadDataIfNeeded() {
if !batchUpdate.isPerforming { if !BatchUpdate.shared.isPerforming {
treeController.rebuild() treeController.rebuild()
outlineView.reloadData() outlineView.reloadData()
} }

View File

@ -42,7 +42,7 @@ struct FeedsImporter {
let feedsToImport = feeds(with: feedDictionaries, accountID: account.accountID) let feedsToImport = feeds(with: feedDictionaries, accountID: account.accountID)
batchUpdate.perform { BatchUpdate.shared.perform {
for feed in feedsToImport { for feed in feedsToImport {
if !account.hasFeed(with: feed.feedID) { if !account.hasFeed(with: feed.feedID) {
let _ = account.addFeed(feed, to: nil) let _ = account.addFeed(feed, to: nil)

View File

@ -38,7 +38,7 @@ struct OPMLImporter {
} }
if let opmlDocument = opmlDocument { if let opmlDocument = opmlDocument {
batchUpdate.perform { BatchUpdate.shared.perform {
account.importOPML(opmlDocument) account.importOPML(opmlDocument)
} }
} }