Don’t save an Account to disk during a refresh session. Wait till it’s over.
This commit is contained in:
parent
c5ed540194
commit
c80e3e86de
|
@ -60,8 +60,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
public var dirty = false {
|
||||
didSet {
|
||||
if dirty {
|
||||
Account.saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||
if dirty && !refreshInProgress {
|
||||
queueSaveToDiskIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
}
|
||||
else {
|
||||
NotificationCenter.default.post(name: .AccountRefreshDidFinish, object: self)
|
||||
queueSaveToDiskIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,6 +495,11 @@ private extension Account {
|
|||
static let unreadCount = "unreadCount"
|
||||
}
|
||||
|
||||
func queueSaveToDiskIfNeeded() {
|
||||
|
||||
Account.saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||
}
|
||||
|
||||
func object(with diskObject: [String: Any]) -> AnyObject? {
|
||||
|
||||
if Feed.isFeedDictionary(diskObject) {
|
||||
|
|
Loading…
Reference in New Issue