Fix OTG batch selection cell refresh
This commit is contained in:
@ -180,10 +180,7 @@ final class WiredCameraTransferViewController: BaseViewController {
|
||||
withReuseIdentifier: WiredTransferPhotoCell.reuseIdentifier,
|
||||
for: indexPath
|
||||
) as! WiredTransferPhotoCell
|
||||
let selected = self?.viewModel.selectedPhotoIds.contains(item.id) == true
|
||||
cell.apply(item: item, selectionMode: self?.viewModel.selectUploadMode == true, selected: selected)
|
||||
cell.onRetry = { [weak self] in self?.viewModel.retryPhoto(photoId: item.id) }
|
||||
cell.onDelete = { [weak self] in self?.confirmDeletePhoto(item.id) }
|
||||
self?.configurePhotoCell(cell, item: item)
|
||||
return cell
|
||||
}
|
||||
dataSource.supplementaryViewProvider = { [weak self] collectionView, kind, indexPath in
|
||||
@ -419,6 +416,7 @@ final class WiredCameraTransferViewController: BaseViewController {
|
||||
snapshot.appendItems(section.photos, toSection: currentSections[index])
|
||||
}
|
||||
dataSource.apply(snapshot, animatingDifferences: true) { [weak self] in
|
||||
self?.reconfigureVisiblePhotoCells()
|
||||
self?.scrollToPendingTimeSlotIfNeeded()
|
||||
}
|
||||
|
||||
@ -486,6 +484,23 @@ final class WiredCameraTransferViewController: BaseViewController {
|
||||
pendingScrollSlotId = nil
|
||||
}
|
||||
|
||||
private func configurePhotoCell(_ cell: WiredTransferPhotoCell, item: TravelAlbumOTGPhotoItem) {
|
||||
let selected = viewModel.selectedPhotoIds.contains(item.id)
|
||||
cell.apply(item: item, selectionMode: viewModel.selectUploadMode, selected: selected)
|
||||
cell.onRetry = { [weak self] in self?.viewModel.retryPhoto(photoId: item.id) }
|
||||
cell.onDelete = { [weak self] in self?.confirmDeletePhoto(item.id) }
|
||||
}
|
||||
|
||||
private func reconfigureVisiblePhotoCells() {
|
||||
for indexPath in collectionView.indexPathsForVisibleItems {
|
||||
guard let cell = collectionView.cellForItem(at: indexPath) as? WiredTransferPhotoCell,
|
||||
let item = dataSource.itemIdentifier(for: indexPath) else {
|
||||
continue
|
||||
}
|
||||
configurePhotoCell(cell, item: item)
|
||||
}
|
||||
}
|
||||
|
||||
private func rebuildStats() {
|
||||
statsCard.arrangedSubviews.forEach { view in
|
||||
statsCard.removeArrangedSubview(view)
|
||||
|
||||
Reference in New Issue
Block a user