Update Account unread count when BatchUpdate did perform.
This commit is contained in:
parent
38954448cb
commit
1e713e3bfd
|
@ -14,7 +14,6 @@
|
|||
842E45E71ED8C747000A8B52 /* DB5.plist in Resources */ = {isa = PBXBuildFile; fileRef = 842E45E61ED8C747000A8B52 /* DB5.plist */; };
|
||||
84513F901FAA63950023A1A9 /* FeedListControlsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */; };
|
||||
845F52ED1FB2B9FC00C10BF0 /* FeedPasteboardWriter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845F52EC1FB2B9FC00C10BF0 /* FeedPasteboardWriter.swift */; };
|
||||
846A7BEC1F872C5600FEFD30 /* BatchUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */; };
|
||||
846E773D1F6EF67A00A165E2 /* Account.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846E773A1F6EF5D700A165E2 /* Account.framework */; };
|
||||
846E773E1F6EF67A00A165E2 /* Account.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E773A1F6EF5D700A165E2 /* Account.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
846E77411F6EF6A100A165E2 /* Database.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; };
|
||||
|
@ -396,7 +395,6 @@
|
|||
842E45E61ED8C747000A8B52 /* DB5.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = DB5.plist; path = Evergreen/Resources/DB5.plist; sourceTree = "<group>"; };
|
||||
84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListControlsView.swift; sourceTree = "<group>"; };
|
||||
845F52EC1FB2B9FC00C10BF0 /* FeedPasteboardWriter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedPasteboardWriter.swift; sourceTree = "<group>"; };
|
||||
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BatchUpdate.swift; path = Evergreen/BatchUpdate.swift; sourceTree = "<group>"; };
|
||||
846E77161F6EF5D000A165E2 /* Database.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Database.xcodeproj; path = Frameworks/Database/Database.xcodeproj; sourceTree = "<group>"; };
|
||||
846E77301F6EF5D600A165E2 /* Account.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Account.xcodeproj; path = Frameworks/Account/Account.xcodeproj; sourceTree = "<group>"; };
|
||||
84702AA31FA27AC0006B8943 /* MarkReadOrUnreadCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkReadOrUnreadCommand.swift; sourceTree = "<group>"; };
|
||||
|
@ -725,7 +723,6 @@
|
|||
842E45CD1ED8C308000A8B52 /* AppNotifications.swift */,
|
||||
84DAEE311F870B390058304B /* DockBadge.swift */,
|
||||
842E45DC1ED8C54B000A8B52 /* Browser.swift */,
|
||||
846A7BEB1F872C5600FEFD30 /* BatchUpdate.swift */,
|
||||
84702AB31FA27AE8006B8943 /* Commands */,
|
||||
842E45E11ED8C681000A8B52 /* MainWindow */,
|
||||
842E45E01ED8C587000A8B52 /* Preferences */,
|
||||
|
@ -1257,7 +1254,6 @@
|
|||
849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */,
|
||||
84E95D241FB1087500552D99 /* ArticlePasteboardWriter.swift in Sources */,
|
||||
84A6B6961FB8DBD2006754AC /* DinosaursWindowController.swift in Sources */,
|
||||
846A7BEC1F872C5600FEFD30 /* BatchUpdate.swift in Sources */,
|
||||
849A975B1ED9EB0D007D329B /* ArticleUtilities.swift in Sources */,
|
||||
84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */,
|
||||
849A975C1ED9EB0D007D329B /* DefaultFeedsImporter.swift in Sources */,
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// BatchUpdates.swift
|
||||
// DataModel
|
||||
//
|
||||
// Created by Brent Simmons on 9/12/16.
|
||||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public typealias BatchUpdateBlock = () -> Void
|
||||
|
||||
public extension Notification.Name {
|
||||
|
||||
public static let BatchUpdateDidFinish = Notification.Name(rawValue: "BatchUpdateDidFinish")
|
||||
}
|
||||
|
||||
final class BatchUpdate {
|
||||
|
||||
static let shared = BatchUpdate()
|
||||
|
||||
private var count = 0
|
||||
|
||||
var isPerforming: Bool {
|
||||
get {
|
||||
return count > 0
|
||||
}
|
||||
}
|
||||
|
||||
func perform(_ batchUpdateBlock: BatchUpdateBlock) {
|
||||
|
||||
incrementCount()
|
||||
batchUpdateBlock()
|
||||
decrementCount()
|
||||
}
|
||||
}
|
||||
|
||||
private extension BatchUpdate {
|
||||
|
||||
func incrementCount() {
|
||||
|
||||
count = count + 1
|
||||
}
|
||||
|
||||
func decrementCount() {
|
||||
|
||||
count = count - 1
|
||||
|
||||
if count < 1 {
|
||||
|
||||
if count < 0 {
|
||||
assertionFailure("Expected batch updates count to be 0 or greater.")
|
||||
count = 0
|
||||
}
|
||||
|
||||
count = 0
|
||||
postBatchUpdateDidPerform()
|
||||
}
|
||||
}
|
||||
|
||||
func postBatchUpdateDidPerform() {
|
||||
|
||||
NotificationCenter.default.post(name: .BatchUpdateDidFinish, object: nil, userInfo: nil)
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ import RSCore
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(userDidAddFeed(_:)), name: .UserDidAddFeed, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidFinish(_:)), name: .BatchUpdateDidFinish, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
|
||||
|
||||
outlineView.reloadData()
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ import RSCore
|
|||
rebuildTreeAndReloadDataIfNeeded()
|
||||
}
|
||||
|
||||
@objc dynamic func batchUpdateDidFinish(_ notification: Notification) {
|
||||
@objc dynamic func batchUpdateDidPerform(_ notification: Notification) {
|
||||
|
||||
rebuildTreeAndReloadDataIfNeeded()
|
||||
}
|
||||
|
|
|
@ -132,6 +132,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
|
||||
|
||||
pullObjectsFromDisk()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
@ -360,6 +362,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func batchUpdateDidPerform(_ note: Notification) {
|
||||
|
||||
updateUnreadCount()
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import Foundation
|
||||
import Data
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
typealias DiskFeedDictionary = [String: Any]
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import Foundation
|
||||
import RSParser
|
||||
import Account
|
||||
import RSCore
|
||||
|
||||
struct OPMLImporter {
|
||||
|
||||
|
|
Loading…
Reference in New Issue