Skip to content

Commit

Permalink
Merge pull request #21 from RonitOfficial/master
Browse files Browse the repository at this point in the history
Single media in single album deselect crash fix
  • Loading branch information
niralishaha25 authored Oct 1, 2024
2 parents 3c0f2b9 + 736fc0f commit 29b66da
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 29b66da

Please sign in to comment.