diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 584e041fe..2c57dc299 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -241,7 +241,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr NotificationCenter.default.addObserver(self, selector: #selector(accountDidDownloadArticles(_:)), name: .AccountDidDownloadArticles, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountStateDidChange(_:)), name: .AccountStateDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(userDidDeleteAccount(_:)), name: .UserDidDeleteAccount, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(containerChildrenDidChange(_:)), name: .ChildrenDidChange, object: nil) NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: .main) { [weak self] _ in Task { @MainActor in @@ -721,6 +721,13 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } } + @objc func userDidDeleteAccount(_ note: Notification) { + undoManager?.removeAllActions() // Undo stack may contain actions for the deleted account. + if representedObjectsContainsAnyPseudoFeed() { + fetchAndReplaceArticlesAsync() + } + } + @objc func containerChildrenDidChange(_ note: Notification) { if representedObjectsContainsAnyPseudoFeed() || representedObjectsContainAnyFolder() { fetchAndReplaceArticlesAsync() diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 652d2fc97..feca7e731 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -553,6 +553,8 @@ struct SidebarItemNode: Hashable, Sendable { @objc func userDidDeleteAccount(_ note: Notification) { Self.logger.debug("SceneCoordinator: userDidDeleteAccount") + undoManager?.removeAllActions() // Undo stack may contain actions for the deleted account. + let cleanupAccount = { if let account = note.userInfo?[Account.UserInfoKey.account] as? Account, let node = self.treeController.rootNode.childNodeRepresentingObject(account) {