Skip to content

Commit

Permalink
Merge pull request #154 from nohana/release/0.9.14
Browse files Browse the repository at this point in the history
0.9.14
  • Loading branch information
tyokujin authored Dec 21, 2022
2 parents cfc0c64 + a4507d2 commit 73aa0c6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions NohanaImagePicker/AssetListSelectableDateSectionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,22 @@ extension AssetListSelectableDateSectionController: PHPhotoLibraryChangeObserver
func photoLibraryDidChange(_ changeInstance: PHChange) {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }

var removedAssets: [PhotoKitAsset] = []
self.nohanaImagePickerController.pickedAssetList.forEach { item in
if let asset = item as? PhotoKitAsset, let changeDetail = changeInstance.changeDetails(for: asset.asset) {
if changeDetail.objectWasDeleted {
removedAssets.append(asset)
}
}
}
for removedAsset in removedAssets {
self.nohanaImagePickerController.dropAsset(removedAsset)
}
if !removedAssets.isEmpty {
self.setToolbarTitle(self.nohanaImagePickerController)
}

self.photoKitAssetList = PhotoKitAssetList(album: self.photoKitAssetList.assetList, mediaType: self.photoKitAssetList.mediaType, ascending: false)
self.dateSectionList = AssetDateSectionCreater().createSections(assetList: self.photoKitAssetList.assetList, options: PhotoKitAssetList.fetchOptions(self.photoKitAssetList.mediaType, ascending: false))
self.isLoading = false
Expand Down

0 comments on commit 73aa0c6

Please sign in to comment.