Skip to content

Commit 9fdc606

Browse files
committed
feat: add integration for attachment manager
1 parent 075300d commit 9fdc606

File tree

51 files changed

+1380
-2873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1380
-2873
lines changed

examples/SampleApp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"react-native-fast-image": "^8.6.3",
4646
"react-native-gesture-handler": "^2.24.0",
4747
"react-native-haptic-feedback": "^2.3.3",
48-
"react-native-image-picker": "^8.2.0",
48+
"react-native-image-picker": "^8.2.1",
4949
"react-native-reanimated": "^3.17.1",
5050
"react-native-safe-area-context": "^5.2.0",
5151
"react-native-screens": "^4.9.1",

examples/TypeScriptMessaging/yarn.lock

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,11 @@
23342334
"@typescript-eslint/types" "8.24.1"
23352335
eslint-visitor-keys "^4.2.0"
23362336

2337+
"@ungap/structured-clone@^1.3.0":
2338+
version "1.3.0"
2339+
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8"
2340+
integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==
2341+
23372342
abort-controller@^3.0.0:
23382343
version "3.0.0"
23392344
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"
@@ -3361,7 +3366,7 @@ emittery@^0.13.1:
33613366
resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad"
33623367
integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==
33633368

3364-
emoji-regex@^10.3.0, emoji-regex@^10.4.0:
3369+
emoji-regex@^10.4.0:
33653370
version "10.4.0"
33663371
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-10.4.0.tgz#03553afea80b3975749cfcb36f776ca268e413d4"
33673372
integrity sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==
@@ -6926,25 +6931,6 @@ statuses@~1.5.0:
69266931
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
69276932
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
69286933

6929-
6930-
version "7.0.0"
6931-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-7.0.0.tgz#ba5439c9a446713356105a40c7d2f90c3ccbf4a3"
6932-
integrity sha512-qjjukVUXl13/cQDCovTAUHMUXgweg6fhh0we2t+C3RI3gN0AaiXMpzejA6RSuArBtezV4AB/mv9BoT7BRTzqeA==
6933-
dependencies:
6934-
"@gorhom/bottom-sheet" "^5.1.1"
6935-
dayjs "1.10.5"
6936-
emoji-regex "^10.3.0"
6937-
i18next "^21.6.14"
6938-
intl-pluralrules "^2.0.1"
6939-
linkifyjs "^4.1.1"
6940-
lodash-es "4.17.21"
6941-
mime-types "^2.1.34"
6942-
path "0.12.7"
6943-
react-native-markdown-package "1.8.2"
6944-
react-native-url-polyfill "^1.3.0"
6945-
stream-chat "^9.0.0"
6946-
use-sync-external-store "^1.4.0"
6947-
69486934
"stream-chat-react-native-core@link:../../package":
69496935
version "0.0.0"
69506936
uid ""
@@ -6968,21 +6954,6 @@ stream-chat@^9.0.0:
69686954
linkifyjs "^4.2.0"
69696955
ws "^8.18.1"
69706956

6971-
stream-chat@^8.57.6:
6972-
version "8.60.0"
6973-
resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-8.60.0.tgz#b67d4fbb185da53fb8ac5fc5759986d6ad7e19a3"
6974-
integrity sha512-7FpO7Wno++r+n+x9aFuXtGYtNO06CIMd2Bxe3doYZLhMfS0nuaXloeFlGcMT0r4U/6bnguz1qQdDJUPNQAS8bQ==
6975-
dependencies:
6976-
"@babel/runtime" "^7.27.0"
6977-
"@types/jsonwebtoken" "~9.0.0"
6978-
"@types/ws" "^7.4.0"
6979-
axios "^1.6.0"
6980-
base64-js "^1.5.1"
6981-
form-data "^4.0.0"
6982-
isomorphic-ws "^4.0.1"
6983-
jsonwebtoken "~9.0.0"
6984-
ws "^7.5.10"
6985-
69866957
strict-uri-encode@^2.0.0:
69876958
version "2.0.0"
69886959
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"

package/expo-package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"types": "types/index.d.ts",
1212
"dependencies": {
1313
"mime": "^4.0.7",
14-
"stream-chat-react-native-core": "7.0.0"
14+
"stream-chat-react-native-core": "link:../"
1515
},
1616
"peerDependencies": {
1717
"expo": ">=51.0.0",

package/native-package/src/optionalDependencies/takePhoto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export const takePhoto = ImagePicker
8888
const date = new Date().toISOString().replace(clearFilter, '_');
8989
return {
9090
cancelled: false,
91-
name: 'video_recording_' + date + '.' + asset.fileName.split('.').pop(),
92-
size: asset.size,
91+
name: 'image_' + date + '.' + asset.uri.split('.').pop(),
92+
size: asset.fileSize,
9393
type: asset.type,
9494
uri: asset.uri,
9595
...size,

package/native-package/yarn.lock

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,11 @@
13011301
dependencies:
13021302
"@types/yargs-parser" "*"
13031303

1304+
"@ungap/structured-clone@^1.3.0":
1305+
version "1.3.0"
1306+
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8"
1307+
integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==
1308+
13041309
abort-controller@^3.0.0:
13051310
version "3.0.0"
13061311
resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392"
@@ -3450,24 +3455,9 @@ statuses@~1.5.0:
34503455
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
34513456
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
34523457

3453-
3454-
version "7.0.0"
3455-
resolved "https://registry.yarnpkg.com/stream-chat-react-native-core/-/stream-chat-react-native-core-7.0.0.tgz#ba5439c9a446713356105a40c7d2f90c3ccbf4a3"
3456-
integrity sha512-qjjukVUXl13/cQDCovTAUHMUXgweg6fhh0we2t+C3RI3gN0AaiXMpzejA6RSuArBtezV4AB/mv9BoT7BRTzqeA==
3457-
dependencies:
3458-
"@gorhom/bottom-sheet" "^5.1.1"
3459-
dayjs "1.10.5"
3460-
emoji-regex "^10.3.0"
3461-
i18next "^21.6.14"
3462-
intl-pluralrules "^2.0.1"
3463-
linkifyjs "^4.1.1"
3464-
lodash-es "4.17.21"
3465-
mime-types "^2.1.34"
3466-
path "0.12.7"
3467-
react-native-markdown-package "1.8.2"
3468-
react-native-url-polyfill "^1.3.0"
3469-
stream-chat "^9.0.0"
3470-
use-sync-external-store "^1.4.0"
3458+
"stream-chat-react-native-core@link:..":
3459+
version "0.0.0"
3460+
uid ""
34713461

34723462
stream-chat@^9.0.0:
34733463
version "9.0.0"

package/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
},
6868
"dependencies": {
6969
"@gorhom/bottom-sheet": "^5.1.1",
70+
"@ungap/structured-clone": "^1.3.0",
7071
"dayjs": "1.10.5",
7172
"emoji-regex": "^10.4.0",
7273
"i18next": "^21.6.14",
@@ -127,6 +128,7 @@
127128
"@types/mime-types": "2.1.4",
128129
"@types/react": "^19.0.0",
129130
"@types/react-test-renderer": "19.0.0",
131+
"@types/ungap__structured-clone": "^1.2.0",
130132
"@types/use-sync-external-store": "^0.0.6",
131133
"@types/uuid": "^10.0.0",
132134
"babel-eslint": "10.1.0",

package/src/components/Attachment/AudioAttachment.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@ import {
1515
VideoProgressData,
1616
VideoSeekResponse,
1717
} from '../../native';
18-
import { AudioUpload, FileTypes } from '../../types/types';
18+
import { AudioConfig, FileTypes } from '../../types/types';
1919
import { getTrimmedAttachmentTitle } from '../../utils/getTrimmedAttachmentTitle';
2020
import { ProgressControl } from '../ProgressControl/ProgressControl';
2121
import { WaveProgressBar } from '../ProgressControl/WaveProgressBar';
2222

2323
dayjs.extend(duration);
2424

25+
export type AudioAttachmentType = AudioConfig & {
26+
asset_url?: string;
27+
id: string;
28+
title?: string;
29+
type: 'audio' | 'voiceRecording';
30+
waveform_data?: number[];
31+
};
32+
2533
export type AudioAttachmentProps = {
26-
item: Omit<AudioUpload, 'state'>;
34+
item: AudioAttachmentType;
2735
onLoad: (index: string, duration: number) => void;
2836
onPlayPause: (index: string, pausedStatus?: boolean) => void;
2937
onProgress: (index: string, progress: number) => void;
@@ -180,9 +188,9 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
180188
useEffect(() => {
181189
if (isExpoCLI) {
182190
const initiateSound = async () => {
183-
if (item && item.file && item.file.uri && NativeHandlers.Sound?.initializeSound) {
191+
if (item && item.asset_url && NativeHandlers.Sound?.initializeSound) {
184192
soundRef.current = await NativeHandlers.Sound.initializeSound(
185-
{ uri: item.file.uri },
193+
{ uri: item.asset_url },
186194
{
187195
pitchCorrectionQuality: 'high',
188196
progressUpdateIntervalMillis: 100,
@@ -318,22 +326,22 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
318326
filenameText,
319327
]}
320328
>
321-
{getTrimmedAttachmentTitle(item.file.name)}
329+
{getTrimmedAttachmentTitle(item.title)}
322330
</Text>
323331
<View style={styles.audioInfo}>
324332
<Text style={[styles.progressDurationText, { color: grey_dark }, progressDurationText]}>
325333
{progressDuration}
326334
</Text>
327335
{!hideProgressBar && (
328336
<View style={[styles.progressControlContainer, progressControlContainer]}>
329-
{item.file.waveform_data ? (
337+
{item.waveform_data ? (
330338
<WaveProgressBar
331339
amplitudesCount={30}
332340
onEndDrag={dragEnd}
333341
onProgressDrag={dragProgress}
334342
onStartDrag={dragStart}
335343
progress={item.progress as number}
336-
waveformData={item.file.waveform_data}
344+
waveformData={item.waveform_data}
337345
/>
338346
) : (
339347
<ProgressControl
@@ -359,7 +367,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
359367
rate={currentSpeed}
360368
soundRef={soundRef as RefObject<SoundReturnType>}
361369
testID='sound-player'
362-
uri={item.file.uri}
370+
uri={item.asset_url}
363371
/>
364372
)}
365373
</View>

package/src/components/Attachment/FileAttachmentGroup.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,14 @@ const FileAttachmentGroupWithContext = (props: FileAttachmentGroupPropsWithConte
111111
isSoundPackageAvailable() ? (
112112
<AudioAttachment
113113
item={{
114+
asset_url: file.asset_url,
114115
duration: file.duration,
115-
file: {
116-
name: file.title as string,
117-
size: file.file_size || 0,
118-
type: file.mime_type || '',
119-
uri: file.asset_url || '',
120-
waveform_data: file.waveform_data,
121-
},
122116
id: index.toString(),
123117
paused: file.paused,
124118
progress: file.progress,
119+
title: file.title,
125120
type: file.type,
121+
waveform_data: file.waveform_data,
126122
}}
127123
onLoad={onLoad}
128124
onPlayPause={onPlayPause}

package/src/components/AttachmentPicker/AttachmentPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ export const AttachmentPicker = React.forwardRef(
245245
numberOfUploads: selectedFiles.length + selectedImages.length,
246246
// `id` is available for Expo MediaLibrary while Cameraroll doesn't share id therefore we use `uri`
247247
selected:
248-
selectedImages.some((image) => image.uri === asset.uri) ||
249-
selectedFiles.some((file) => file.uri === asset.uri),
248+
selectedImages.some((image) => (image?.uri ? image.uri === asset.uri : false)) ||
249+
selectedFiles.some((file) => (file?.uri ? file.uri === asset.uri : false)),
250250
selectedFiles,
251251
selectedImages,
252252
setSelectedFiles,

package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const AttachmentPickerSelectionBar = () => {
3636
hasCameraPicker,
3737
hasFilePicker,
3838
hasImagePicker,
39-
imageUploads,
4039
openPollCreationDialog,
4140
pickFile,
4241
sendMessage,
@@ -82,10 +81,7 @@ export const AttachmentPickerSelectionBar = () => {
8281
testID='upload-photo-touchable'
8382
>
8483
<View style={[styles.icon, icon]}>
85-
<ImageSelectorIcon
86-
numberOfImageUploads={imageUploads.length}
87-
selectedPicker={selectedPicker}
88-
/>
84+
<ImageSelectorIcon selectedPicker={selectedPicker} />
8985
</View>
9086
</TouchableOpacity>
9187
) : null}
@@ -96,10 +92,7 @@ export const AttachmentPickerSelectionBar = () => {
9692
testID='upload-file-touchable'
9793
>
9894
<View style={[styles.icon, icon]}>
99-
<FileSelectorIcon
100-
numberOfImageUploads={imageUploads.length}
101-
selectedPicker={selectedPicker}
102-
/>
95+
<FileSelectorIcon selectedPicker={selectedPicker} />
10396
</View>
10497
</TouchableOpacity>
10598
) : null}
@@ -112,10 +105,7 @@ export const AttachmentPickerSelectionBar = () => {
112105
testID='take-photo-touchable'
113106
>
114107
<View style={[styles.icon, icon]}>
115-
<CameraSelectorIcon
116-
numberOfImageUploads={imageUploads.length}
117-
selectedPicker={selectedPicker}
118-
/>
108+
<CameraSelectorIcon selectedPicker={selectedPicker} />
119109
</View>
120110
</TouchableOpacity>
121111
) : null}
@@ -128,10 +118,7 @@ export const AttachmentPickerSelectionBar = () => {
128118
testID='take-photo-touchable'
129119
>
130120
<View style={[styles.icon, { marginTop: 4 }, icon]}>
131-
<VideoRecorderSelectorIcon
132-
numberOfImageUploads={imageUploads.length}
133-
selectedPicker={selectedPicker}
134-
/>
121+
<VideoRecorderSelectorIcon selectedPicker={selectedPicker} />
135122
</View>
136123
</TouchableOpacity>
137124
) : null}

0 commit comments

Comments
 (0)