stream-chat-react-native 9.0.0-beta.8 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +30 -0
- package/android/src/main/java/com/streamchatreactnative/StreamChatReactNative.java +0 -153
- package/android/src/main/java/com/streamchatreactnative/StreamChatReactNativeModule.java +2 -15
- package/android/src/main/java/com/streamchatreactnative/StreamChatReactNativePackage.java +32 -0
- package/android/src/main/java/com/streamchatreactnative/shared/StreamVideoThumbnailGenerator.kt +159 -0
- package/android/src/newarch/com/streamchatreactnative/StreamVideoThumbnailModule.kt +50 -0
- package/android/src/oldarch/com/streamchatreactnative/StreamChatReactNative.java +1 -1
- package/ios/StreamChatReactNative.mm +16 -148
- package/ios/shared/StreamVideoThumbnail.h +14 -0
- package/ios/shared/StreamVideoThumbnail.mm +56 -0
- package/ios/shared/StreamVideoThumbnailGenerator.swift +338 -0
- package/package.json +15 -12
- package/react-native.config.js +13 -0
- package/src/handlers/compressImage.ts +0 -1
- package/src/native/NativeStreamChatReactNative.ts +0 -1
- package/src/native/NativeStreamVideoThumbnail.ts +14 -0
- package/src/native/index.tsx +0 -2
- package/src/native/types.ts +2 -0
- package/src/native/videoThumbnail.ts +8 -0
- package/src/optionalDependencies/Audio.ts +1 -1
- package/src/optionalDependencies/Sound.tsx +349 -43
- package/src/optionalDependencies/generateThumbnail.ts +8 -0
- package/src/optionalDependencies/getPhotos.ts +28 -12
- package/src/optionalDependencies/pickImage.ts +34 -9
- package/src/optionalDependencies/takePhoto.ts +7 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import mime from 'mime';
|
|
4
|
+
|
|
3
5
|
import { PickImageOptions } from 'stream-chat-react-native-core';
|
|
6
|
+
|
|
7
|
+
import { generateThumbnails } from './generateThumbnail';
|
|
8
|
+
|
|
4
9
|
let ImagePicker;
|
|
5
10
|
|
|
6
11
|
try {
|
|
@@ -24,17 +29,37 @@ export const pickImage = ImagePicker
|
|
|
24
29
|
return { askToOpenSettings: true, cancelled: true };
|
|
25
30
|
}
|
|
26
31
|
if (!canceled) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
duration: asset.duration ? asset.duration * 1000 : undefined, // in milliseconds
|
|
30
|
-
name: asset.fileName,
|
|
31
|
-
size: asset.fileSize,
|
|
32
|
-
type:
|
|
32
|
+
const assetsWithType = result.assets.map((asset) => {
|
|
33
|
+
const type =
|
|
33
34
|
asset.type ||
|
|
34
35
|
mime.getType(asset.fileName || asset.uri) ||
|
|
35
|
-
(asset.duration ? 'video/*' : 'image/*')
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
(asset.duration ? 'video/*' : 'image/*');
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
asset,
|
|
40
|
+
isVideo: type.includes('video'),
|
|
41
|
+
type,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const videoUris = assetsWithType
|
|
45
|
+
.filter(({ asset, isVideo }) => isVideo && !!asset.uri)
|
|
46
|
+
.map(({ asset }) => asset.uri);
|
|
47
|
+
const videoThumbnailResults = await generateThumbnails(videoUris);
|
|
48
|
+
|
|
49
|
+
const assets = assetsWithType.map(({ asset, isVideo, type }) => {
|
|
50
|
+
const thumbnailResult =
|
|
51
|
+
isVideo && asset.uri ? videoThumbnailResults[asset.uri] : undefined;
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
...asset,
|
|
55
|
+
duration: asset.duration ? asset.duration * 1000 : undefined, // in milliseconds
|
|
56
|
+
name: asset.fileName,
|
|
57
|
+
size: asset.fileSize,
|
|
58
|
+
thumb_url: thumbnailResult?.uri || undefined,
|
|
59
|
+
type,
|
|
60
|
+
uri: asset.uri,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
38
63
|
return { assets, cancelled: false };
|
|
39
64
|
} else {
|
|
40
65
|
return { cancelled: true };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AppState, Image, PermissionsAndroid, Platform } from 'react-native';
|
|
2
|
+
|
|
2
3
|
import mime from 'mime';
|
|
3
4
|
|
|
5
|
+
import { generateThumbnails } from './generateThumbnail';
|
|
6
|
+
|
|
4
7
|
let ImagePicker;
|
|
5
8
|
|
|
6
9
|
try {
|
|
@@ -54,12 +57,16 @@ export const takePhoto = ImagePicker
|
|
|
54
57
|
if (assetType.includes('video')) {
|
|
55
58
|
const clearFilter = new RegExp('[.:]', 'g');
|
|
56
59
|
const date = new Date().toISOString().replace(clearFilter, '_');
|
|
60
|
+
const thumbnailResults = await generateThumbnails([asset.uri]);
|
|
61
|
+
const thumbnailResult = thumbnailResults[asset.uri];
|
|
62
|
+
|
|
57
63
|
return {
|
|
58
64
|
...asset,
|
|
59
65
|
cancelled: false,
|
|
60
66
|
duration: asset.duration * 1000,
|
|
61
67
|
name: 'video_recording_' + date + '.' + asset.fileName.split('.').pop(),
|
|
62
68
|
size: asset.fileSize,
|
|
69
|
+
thumb_url: thumbnailResult?.uri || undefined,
|
|
63
70
|
type: assetType,
|
|
64
71
|
uri: asset.uri,
|
|
65
72
|
};
|