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