From 4a0a263f5dfeff8edea1b09d2133265695eea801 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 18 Jan 2026 10:17:43 -0800 Subject: [PATCH] Defer rebuilding backing stores when a BatchUpdate is in progress. Fix #4949. --- iOS/SceneCoordinator.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index e88c24e74..43f0a5b96 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -461,7 +461,7 @@ struct FeedNode: Hashable, Sendable { guard AccountManager.shared.areUnreadCountsInitialized else { return } - + Self.logger.debug("SceneCoordinator: unreadCountDidChange \(note.object.debugDescription)") queueRebuildBackingStores() } @@ -1609,11 +1609,19 @@ private extension SceneCoordinator { static var rebuildCount = 0 func rebuildBackingStores(initialLoad: Bool = false, updateExpandedNodes: (() -> Void)? = nil, completion: (() -> Void)? = nil) { +#if DEBUG Self.logger.debug("SceneCoordinator: rebuildBackingStores: # \(Self.rebuildCount) initialLoad \(initialLoad ? "true" : "false")") Self.rebuildCount += 1 +#endif - if isRebuildingBackingStores { - Self.logger.debug("SceneCoordinator: rebuildBackingStores — skipping because isRebuildingBackingStores") + if isRebuildingBackingStores || BatchUpdate.shared.isPerforming { +#if DEBUG + if isRebuildingBackingStores { + Self.logger.debug("SceneCoordinator: rebuildBackingStores — skipping because isRebuildingBackingStores") + } else { + Self.logger.debug("SceneCoordinator: rebuildBackingStores — skipping because BatchUpdate.shared.isPerforming") + } +#endif queueRebuildBackingStores() return }