From b9ae60395b27f831923a990690346fa95930fb2c Mon Sep 17 00:00:00 2001 From: Michal Rentka Date: Tue, 3 Dec 2024 14:14:52 +0100 Subject: [PATCH] Code review changes --- .../Views/ItemDetailCollectionViewHandler.swift | 2 +- .../Detail/PDF/Views/PDFAnnotationsViewController.swift | 8 +++----- .../Detail/PDF/Views/PDFThumbnailsViewController.swift | 2 +- .../General/Views/CollectionsPickerViewController.swift | 4 +--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Zotero/Scenes/Detail/ItemDetail/Views/ItemDetailCollectionViewHandler.swift b/Zotero/Scenes/Detail/ItemDetail/Views/ItemDetailCollectionViewHandler.swift index 310e40ad3..cc7fcdba0 100644 --- a/Zotero/Scenes/Detail/ItemDetail/Views/ItemDetailCollectionViewHandler.swift +++ b/Zotero/Scenes/Detail/ItemDetail/Views/ItemDetailCollectionViewHandler.swift @@ -535,7 +535,7 @@ final class ItemDetailCollectionViewHandler: NSObject { let toReload = rowsToReload(from: oldRows, to: newRows, in: section) if !toReload.isEmpty { - snapshot.reloadItems(toReload) + snapshot.reconfigureItems(toReload) } dataSource.apply(snapshot, animatingDifferences: animated) diff --git a/Zotero/Scenes/Detail/PDF/Views/PDFAnnotationsViewController.swift b/Zotero/Scenes/Detail/PDF/Views/PDFAnnotationsViewController.swift index 4dc1f78bf..06e692179 100644 --- a/Zotero/Scenes/Detail/PDF/Views/PDFAnnotationsViewController.swift +++ b/Zotero/Scenes/Detail/PDF/Views/PDFAnnotationsViewController.swift @@ -74,11 +74,9 @@ final class PDFAnnotationsViewController: UIViewController { var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([0]) snapshot.appendItems(viewModel.state.sortedKeys) - dataSource.apply(snapshot, animatingDifferences: false) - if let key = viewModel.state.focusSidebarKey, let indexPath = dataSource.indexPath(for: key) { - inMainThread { [weak self] in - self?.tableView.selectRow(at: indexPath, animated: false, scrollPosition: .middle) - } + dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in + guard let self, let key = viewModel.state.focusSidebarKey, let indexPath = dataSource.indexPath(for: key) else { return } + tableView.selectRow(at: indexPath, animated: false, scrollPosition: .middle) } } diff --git a/Zotero/Scenes/Detail/PDF/Views/PDFThumbnailsViewController.swift b/Zotero/Scenes/Detail/PDF/Views/PDFThumbnailsViewController.swift index f569b38ed..a18ad6337 100644 --- a/Zotero/Scenes/Detail/PDF/Views/PDFThumbnailsViewController.swift +++ b/Zotero/Scenes/Detail/PDF/Views/PDFThumbnailsViewController.swift @@ -112,7 +112,7 @@ class PDFThumbnailsViewController: UICollectionViewController { guard let self else { return } var snapshot = dataSource.snapshot() let label = dataSource.snapshot().itemIdentifiers[index] - snapshot.reloadItems([label]) + snapshot.reconfigureItems([label]) dataSource.apply(snapshot) } return diff --git a/Zotero/Scenes/General/Views/CollectionsPickerViewController.swift b/Zotero/Scenes/General/Views/CollectionsPickerViewController.swift index 8f88f53dd..06fd25661 100644 --- a/Zotero/Scenes/General/Views/CollectionsPickerViewController.swift +++ b/Zotero/Scenes/General/Views/CollectionsPickerViewController.swift @@ -133,9 +133,7 @@ class CollectionsPickerViewController: UICollectionViewController { guard let self else { return } dataSource.apply(state.collectionTree.createSnapshot(collapseState: .expandedAll), to: 0, animatingDifferences: animated) { [weak self] in guard let self, multipleSelectionAllowed else { return } - inMainThread { [weak self] in - self?.select(selected: state.selected, tree: state.collectionTree) - } + select(selected: state.selected, tree: state.collectionTree) } } }