Skip to content

Commit

Permalink
Single media in single album deselect crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RonitOfficial committed Oct 1, 2024
1 parent 3c0f2b9 commit 736fc0f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Source/Pages/Gallery/YPLibraryVC+CollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ extension YPLibraryVC {

// Replace the current selected image with the previously selected one
if let previouslySelectedIndexPath = selectedIndexPaths.last {
v.collectionView.deselectItem(at: indexPath, animated: false)
v.collectionView.selectItem(at: previouslySelectedIndexPath, animated: false, scrollPosition: [])
if(v.collectionView.indexPathsForSelectedItems?.contains(indexPath) ?? false){
v.collectionView.deselectItem(at: indexPath, animated: false)
}
if(v.collectionView.indexPathsForVisibleItems.contains(previouslySelectedIndexPath)){
v.collectionView.selectItem(at: previouslySelectedIndexPath, animated: false, scrollPosition: [])
}
currentlySelectedIndex = previouslySelectedIndexPath.row
changeAsset(mediaManager.getAsset(at: previouslySelectedIndexPath.row))
}
Expand Down

0 comments on commit 736fc0f

Please sign in to comment.