Avoid resetting the save timer so often during a refresh session. Instead just remove it (if refreshing) and add it back when the refresh session ends.

This commit is contained in:
Brent Simmons 2017-10-07 20:24:58 -07:00
parent 0ba557736e
commit c52eb024ab

View File

@ -46,8 +46,16 @@ public final class Account: DisplayNameProvider, Hashable {
var username: String?
var saveTimer: Timer?
private var dirty = false {
var dirty = false {
didSet {
if refreshInProgress {
if let _ = saveTimer {
removeSaveTimer()
}
return
}
if dirty {
resetSaveTimer()
}
@ -65,6 +73,9 @@ public final class Account: DisplayNameProvider, Hashable {
}
else {
NotificationCenter.default.post(name: .AccountRefreshDidFinish, object: self)
if dirty {
resetSaveTimer()
}
}
}
}