From 7def2ae8d0e1694d7533e7bdbfc94ebf729644c0 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 24 Feb 2018 15:54:32 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20where=20deleting=20from=20the=20sid?= =?UTF-8?q?ebar=20would=20not=20stick=20across=20runs=20of=20the=20app=20s?= =?UTF-8?q?ometimes=20=E2=80=94=C2=A0whatever=20you=20deleted=20could=20co?= =?UTF-8?q?me=20back.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Account/Account.swift | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 76d32af9b..81c38f919 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -117,6 +117,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(childrenDidChange(_:)), name: .ChildrenDidChange, object: nil) pullObjectsFromDisk() @@ -447,23 +448,34 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } } - @objc func displayNameDidChange(_ note: Notification) { + @objc func childrenDidChange(_ note: Notification) { - if let feed = note.object as? Feed, let feedAccount = feed.account, feedAccount === self { + guard let object = note.object else { + return + } + if let account = object as? Account, account === self { dirty = true } - if let folder = note.object as? Folder, let folderAccount = folder.account, folderAccount === self { + if let folder = object as? Folder, folder.account === self { + dirty = true + } + } + + @objc func displayNameDidChange(_ note: Notification) { + + if let feed = note.object as? Feed, feed.account === self { + dirty = true + } + if let folder = note.object as? Folder, folder.account === self { dirty = true } } @objc func saveToDiskIfNeeded() { - guard dirty else { - return + if dirty { + saveToDisk() } - saveToDisk() - dirty = false } // MARK: - Equatable @@ -563,6 +575,7 @@ private extension Account { catch let error as NSError { NSApplication.shared.presentError(error) } + dirty = false } }