From c80e3e86de086f8c75be2f1adf8472880d95b126 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 17 Feb 2018 18:02:40 -0800 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20save=20an=20Account=20to=20disk?= =?UTF-8?q?=20during=20a=20refresh=20session.=20Wait=20till=20it=E2=80=99s?= =?UTF-8?q?=20over.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Account/Account.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 16a7459ea..76d32af9b 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -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) {