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 {
|
public var dirty = false {
|
||||||
didSet {
|
didSet {
|
||||||
if dirty {
|
if dirty && !refreshInProgress {
|
||||||
Account.saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
queueSaveToDiskIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NotificationCenter.default.post(name: .AccountRefreshDidFinish, object: self)
|
NotificationCenter.default.post(name: .AccountRefreshDidFinish, object: self)
|
||||||
|
queueSaveToDiskIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,6 +495,11 @@ private extension Account {
|
||||||
static let unreadCount = "unreadCount"
|
static let unreadCount = "unreadCount"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func queueSaveToDiskIfNeeded() {
|
||||||
|
|
||||||
|
Account.saveQueue.add(self, #selector(saveToDiskIfNeeded))
|
||||||
|
}
|
||||||
|
|
||||||
func object(with diskObject: [String: Any]) -> AnyObject? {
|
func object(with diskObject: [String: Any]) -> AnyObject? {
|
||||||
|
|
||||||
if Feed.isFeedDictionary(diskObject) {
|
if Feed.isFeedDictionary(diskObject) {
|
||||||
|
|
Loading…
Reference in New Issue