Skip to content

Commit 6a697d5

Browse files
committed
fix handle exist assets
1 parent ec972e9 commit 6a697d5

File tree

4 files changed

+25
-69
lines changed

4 files changed

+25
-69
lines changed

example/src/App.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@ import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
55
import MultipleImagePicker from '@baronha/react-native-multiple-image-picker';
66

77
export default function App() {
8-
const [images, setImages] = useState([]);
8+
const [images, setImages] = useState([
9+
{
10+
FileId: '4844',
11+
FileName:
12+
'https://dev.pety.vn/files/images/2091.1614509942.kitten---4216.mp4',
13+
FileThumbnail:
14+
'https://dev.pety.vn/files/images/thumbs/2091.1614509942.kitten---4216.mp4.jpg',
15+
IsImage: '0',
16+
IsVideo: '1',
17+
Name: 'Kitten - 4216.mp4',
18+
PostId: '4841',
19+
idx: 0,
20+
path:
21+
'https://dev.pety.vn/files/images/thumbs/2091.1614509942.kitten---4216.mp4.jpg',
22+
url: 'https://dev.pety.vn/files/images/2091.1614509942.kitten---4216.mp4',
23+
},
24+
]);
925

1026
const openPicker = async () => {
1127
try {

ios/MultipleImagePicker.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
5757

5858
@objc(openPicker:withResolver:withRejecter:)
5959
func openPicker(options: NSDictionary, resolve:@escaping RCTPromiseResolveBlock,reject:@escaping RCTPromiseRejectBlock) -> Void {
60-
videoCount = 0
6160
self.setConfiguration(options: options, resolve: resolve, reject: reject)
6261
let viewController = CustomPhotoPickerViewController()
6362
viewController.delegate = self
@@ -121,9 +120,13 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
121120
}
122121

123122
func handleSelectedAssets(selecteds: NSArray){
124-
if(selecteds.count != self.selectedAssets.count){
123+
let assets = selecteds.filter{ ($0 as! NSObject).value(forKey: "localIdentifier") != nil }
124+
videoCount = selecteds.filter{ ($0 as! NSObject).value(forKey: "type") as? String == "video" }.count
125+
126+
print("videoCount", videoCount)
127+
if(assets.count != self.selectedAssets.count){
125128
var assets = [TLPHAsset]();
126-
for index in 0..<selecteds.count {
129+
for index in 0..<assets.count {
127130
let value = selecteds[index]
128131
let localIdentifier = (value as! NSObject).value(forKey: "localIdentifier") as! String
129132
if(!localIdentifier.isEmpty){
@@ -222,6 +225,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
222225
return;
223226
}
224227
let selections = NSMutableArray.init(array: withTLPHAssets);
228+
self.selectedAssets = withTLPHAssets
225229
//imageRequestOptions
226230
let imageRequestOptions = PHImageRequestOptions();
227231
imageRequestOptions.deliveryMode = .fastFormat;
@@ -272,7 +276,6 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate,UINavi
272276

273277
func canSelectAsset(phAsset: PHAsset) -> Bool {
274278
let maxVideo = self.options["maxVideo"]
275-
print("maxVideo", maxVideo)
276279
if(phAsset.mediaType == .video){
277280
if(videoCount == maxVideo as! Int){
278281
showExceededMaximumAlert(vc: self.getTopMostViewController()!, isVideo: true)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@baronha/react-native-multiple-image-picker",
3-
"version": "0.2.3",
3+
"version": "0.2.5",
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",
@@ -57,7 +57,6 @@
5757
"eslint": "^7.2.0",
5858
"eslint-config-prettier": "^7.0.0",
5959
"eslint-plugin-prettier": "^3.1.3",
60-
"husky": "^4.2.5",
6160
"jest": "^26.0.1",
6261
"pod-install": "^0.1.0",
6362
"prettier": "^2.0.5",

yarn.lock

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,11 +3032,6 @@ compare-func@^2.0.0:
30323032
array-ify "^1.0.0"
30333033
dot-prop "^5.1.0"
30343034

3035-
compare-versions@^3.6.0:
3036-
version "3.6.0"
3037-
resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62"
3038-
integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==
3039-
30403035
component-emitter@^1.2.1:
30413036
version "1.3.0"
30423037
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
@@ -4358,13 +4353,6 @@ find-up@^4.0.0, find-up@^4.1.0:
43584353
locate-path "^5.0.0"
43594354
path-exists "^4.0.0"
43604355

4361-
find-versions@^4.0.0:
4362-
version "4.0.0"
4363-
resolved "https://registry.yarnpkg.com/find-versions/-/find-versions-4.0.0.tgz#3c57e573bf97769b8cb8df16934b627915da4965"
4364-
integrity sha512-wgpWy002tA+wgmO27buH/9KzyEOQnKsG/R0yrcjPT9BOFm0zRBVQbZ95nRGXWMywS8YR5knRbpohio0bcJABxQ==
4365-
dependencies:
4366-
semver-regex "^3.1.2"
4367-
43684356
flat-cache@^3.0.4:
43694357
version "3.0.4"
43704358
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
@@ -4891,22 +4879,6 @@ human-signals@^2.1.0:
48914879
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
48924880
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==
48934881

4894-
husky@^4.2.5:
4895-
version "4.3.8"
4896-
resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.8.tgz#31144060be963fd6850e5cc8f019a1dfe194296d"
4897-
integrity sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow==
4898-
dependencies:
4899-
chalk "^4.0.0"
4900-
ci-info "^2.0.0"
4901-
compare-versions "^3.6.0"
4902-
cosmiconfig "^7.0.0"
4903-
find-versions "^4.0.0"
4904-
opencollective-postinstall "^2.0.2"
4905-
pkg-dir "^5.0.0"
4906-
please-upgrade-node "^3.2.0"
4907-
slash "^3.0.0"
4908-
which-pm-runs "^1.0.0"
4909-
49104882
iconv-lite@0.4.24, iconv-lite@^0.4.17, iconv-lite@^0.4.24:
49114883
version "0.4.24"
49124884
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
@@ -7130,11 +7102,6 @@ open@^6.2.0:
71307102
dependencies:
71317103
is-wsl "^1.1.0"
71327104

7133-
opencollective-postinstall@^2.0.2:
7134-
version "2.0.3"
7135-
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259"
7136-
integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==
7137-
71387105
optionator@^0.8.1:
71397106
version "0.8.3"
71407107
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
@@ -7492,20 +7459,6 @@ pkg-dir@^4.2.0:
74927459
dependencies:
74937460
find-up "^4.0.0"
74947461

7495-
pkg-dir@^5.0.0:
7496-
version "5.0.0"
7497-
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-5.0.0.tgz#a02d6aebe6ba133a928f74aec20bafdfe6b8e760"
7498-
integrity sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==
7499-
dependencies:
7500-
find-up "^5.0.0"
7501-
7502-
please-upgrade-node@^3.2.0:
7503-
version "3.2.0"
7504-
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
7505-
integrity sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==
7506-
dependencies:
7507-
semver-compare "^1.0.0"
7508-
75097462
plist@^3.0.1:
75107463
version "3.0.1"
75117464
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.1.tgz#a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c"
@@ -8325,23 +8278,13 @@ scheduler@0.19.1:
83258278
loose-envify "^1.1.0"
83268279
object-assign "^4.1.1"
83278280

8328-
semver-compare@^1.0.0:
8329-
version "1.0.0"
8330-
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
8331-
integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w=
8332-
83338281
semver-diff@^3.1.1:
83348282
version "3.1.1"
83358283
resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-3.1.1.tgz#05f77ce59f325e00e2706afd67bb506ddb1ca32b"
83368284
integrity sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg==
83378285
dependencies:
83388286
semver "^6.3.0"
83398287

8340-
semver-regex@^3.1.2:
8341-
version "3.1.2"
8342-
resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.2.tgz#34b4c0d361eef262e07199dbef316d0f2ab11807"
8343-
integrity sha512-bXWyL6EAKOJa81XG1OZ/Yyuq+oT0b2YLlxx7c+mrdYPaPbnj6WgVULXhinMIeZGufuUBu/eVRqXEhiv4imfwxA==
8344-
83458288
"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
83468289
version "5.7.1"
83478290
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
@@ -9493,11 +9436,6 @@ which-module@^2.0.0:
94939436
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
94949437
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
94959438

9496-
which-pm-runs@^1.0.0:
9497-
version "1.0.0"
9498-
resolved "https://registry.yarnpkg.com/which-pm-runs/-/which-pm-runs-1.0.0.tgz#670b3afbc552e0b55df6b7780ca74615f23ad1cb"
9499-
integrity sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=
9500-
95019439
which@^1.2.9:
95029440
version "1.3.1"
95039441
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"

0 commit comments

Comments
 (0)