Skip to content

Commit 7d7f5c9

Browse files
committed
fix: fix condition
1 parent a7998d8 commit 7d7f5c9

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

ios/MultipleImagePicker.swift

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,18 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate, UINav
130130
let assetsExist = selectedList.filter { ($0 as! NSObject).value(forKey: "localIdentifier") != nil }
131131
self.videoCount = selectedList.filter { ($0 as! NSObject).value(forKey: "type") as? String == "video" }.count
132132

133-
let existLastItem = (assetsExist.last as? [String: Any])?["localIdentifier"] as? String
134-
let selectedLastItem = self.selectedAssets.last?.phAsset?.localIdentifier as? String
135-
136-
// compare count & last item's localIdentifier => handle exist list
137-
if assetsExist.count != self.selectedAssets.count && selectedLastItem != existLastItem {
138-
var assets = [TLPHAsset]()
139-
for index in 0 ..< assetsExist.count {
140-
let value = assetsExist[index]
141-
let localIdentifier = (value as! NSObject).value(forKey: "localIdentifier") as! String
142-
if !localIdentifier.isEmpty {
143-
var TLAsset = TLPHAsset.asset(with: localIdentifier)
144-
TLAsset?.selectedOrder = index + 1
145-
assets.insert(TLAsset!, at: index)
146-
}
133+
var assets = [TLPHAsset]()
134+
for index in 0 ..< assetsExist.count {
135+
let value = assetsExist[index]
136+
let localIdentifier = (value as! NSObject).value(forKey: "localIdentifier") as! String
137+
if !localIdentifier.isEmpty {
138+
var TLAsset = TLPHAsset.asset(with: localIdentifier)
139+
TLAsset?.selectedOrder = index + 1
140+
assets.insert(TLAsset!, at: index)
147141
}
148-
self.selectedAssets = assets
149-
self.videoCount = assets.filter { $0.phAsset?.mediaType == .video }.count
150142
}
143+
self.selectedAssets = assets
144+
self.videoCount = assets.filter { $0.phAsset?.mediaType == .video }.count
151145
}
152146

153147
func createAttachmentResponse(filePath: String?, withFilename filename: String?, withType type: String?, withAsset asset: PHAsset, withTLAsset TLAsset: TLPHAsset) -> [AnyHashable: Any]? {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@baronha/react-native-multiple-image-picker",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "react-native-multiple-image-picker enables application to pick images and videos from multiple smart album in iOS/Android, similar to the current facebook app.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

0 commit comments

Comments
 (0)