Skip to content

Commit 72d7c7d

Browse files
committed
fix: issues with video preview
1 parent b1fadc0 commit 72d7c7d

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

package/src/components/AttachmentPicker/components/AttachmentPickerItem.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {
4848
},
4949
} = useTheme();
5050

51-
const { duration: videoDuration, uri } = asset;
51+
const { duration: videoDuration, id: assetId, originalUri, uri } = asset;
5252

5353
const durationLabel = getDurationLabelFromDuration(videoDuration);
5454

@@ -58,16 +58,17 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {
5858
const patchVideoFile = (files: File[]) => {
5959
// We need a mime-type to upload a video file.
6060
const mimeType = lookup(asset.name) || 'multipart/form-data';
61+
console.log('SENDING: ', uri, originalUri);
6162
return [
6263
...files,
6364
{
6465
duration: asset.duration,
6566
id: asset.id,
6667
mimeType,
6768
name: asset.name,
68-
originalUri: asset.originalUri,
69+
originalUri,
6970
size: asset.size,
70-
uri: asset.uri,
71+
uri,
7172
},
7273
];
7374
};
@@ -86,7 +87,7 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {
8687
setSelectedFiles((files) =>
8788
// `id` is available for Expo MediaLibrary while Cameraroll doesn't share id therefore we use `uri`
8889
files.filter((file) =>
89-
file.id ? file.id !== asset.id : file.uri !== asset.uri && file.originalUri !== asset.uri,
90+
file.id ? file.id !== assetId : file.uri !== uri && file.originalUri !== uri,
9091
),
9192
);
9293
} else {
@@ -97,7 +98,7 @@ const AttachmentVideo = (props: AttachmentVideoProps) => {
9798
return (
9899
<TouchableOpacity onPress={onPressVideo}>
99100
<ImageBackground
100-
source={{ uri }}
101+
source={{ uri: originalUri }}
101102
style={[
102103
{
103104
height: size,
@@ -147,7 +148,7 @@ const AttachmentImage = (props: AttachmentImageProps) => {
147148

148149
const size = vw(100) / (numberOfAttachmentPickerImageColumns || 3) - 2;
149150

150-
const { uri } = asset;
151+
const { id: assetId, originalUri, uri } = asset;
151152

152153
const updateSelectedImages = () => {
153154
if (numberOfUploads >= maxNumberOfFiles) {
@@ -162,9 +163,7 @@ const AttachmentImage = (props: AttachmentImageProps) => {
162163
// `id` is available for Expo MediaLibrary while Cameraroll doesn't share id therefore we use `uri`
163164
setSelectedImages((images) =>
164165
images.filter((image) =>
165-
image.id
166-
? image.id !== asset.id
167-
: image.uri !== asset.uri && image.originalUri !== asset.uri,
166+
assetId ? image.id !== assetId : image.uri !== uri && originalUri !== uri,
168167
),
169168
);
170169
} else {
@@ -175,7 +174,7 @@ const AttachmentImage = (props: AttachmentImageProps) => {
175174
return (
176175
<TouchableOpacity onPress={onPressImage}>
177176
<ImageBackground
178-
source={{ uri }}
177+
source={{ uri: originalUri }}
179178
style={[
180179
{
181180
height: size,

0 commit comments

Comments
 (0)