From 8e63a8cd549971298fb85ea58fd8cff13ecf4381 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 16 Mar 2026 14:27:20 -0700 Subject: [PATCH] Clear undo stack on deleting an account. --- Mac/MainWindow/Timeline/TimelineViewController.swift | 9 ++++++++- iOS/SceneCoordinator.swift | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) 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) {