From 19dffd34a88d802808f68df675ea16e9d6ddad43 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 19 Jan 2026 20:46:51 -0800 Subject: [PATCH] Use dataSource instead of tree model, since dataSource is source of truth for the UI. --- .../MainFeedCollectionViewController.swift | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/iOS/MainFeed/MainFeedCollectionViewController.swift b/iOS/MainFeed/MainFeedCollectionViewController.swift index 15c95c814..526e42cae 100644 --- a/iOS/MainFeed/MainFeedCollectionViewController.swift +++ b/iOS/MainFeed/MainFeedCollectionViewController.swift @@ -641,18 +641,18 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab return } - let node: Node? = coordinator.rootNode.descendantNodeRepresentingObject(unreadCountProvider as AnyObject) - - guard let unreadCountNode = node, let indexPath = coordinator.indexPathFor(unreadCountNode) else { - return - } - - if let cell = collectionView.cellForItem(at: indexPath) as? MainFeedCollectionViewCell { - cell.unreadCount = unreadCountProvider.unreadCount - } - - if let cell = collectionView.cellForItem(at: indexPath) as? MainFeedCollectionViewFolderCell { - cell.unreadCount = unreadCountProvider.unreadCount + for cell in collectionView.visibleCells { + guard let indexPath = collectionView.indexPath(for: cell), + let sidebarItemNode = dataSource.itemIdentifier(for: indexPath), + sidebarItemNode.node.representedObject === unreadCountProvider as AnyObject else { + continue + } + if let feedCell = cell as? MainFeedCollectionViewCell { + feedCell.unreadCount = unreadCountProvider.unreadCount + } + if let folderCell = cell as? MainFeedCollectionViewFolderCell { + folderCell.unreadCount = unreadCountProvider.unreadCount + } } }