Skip to content

Commit fa002ca

Browse files
fix: allow images attached through file picker to display in gallery view
1 parent bf31df3 commit fa002ca

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

package/src/components/MessageList/__tests__/__snapshots__/MessageList.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ exports[`MessageList should render the message list and match snapshot 1`] = `
931931
]
932932
}
933933
>
934-
Sep 3
934+
Sep 7
935935
</Text>
936936
</View>
937937
</View>

package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ exports[`Thread should match thread snapshot 1`] = `
893893
]
894894
}
895895
>
896-
Sep 3
896+
Sep 7
897897
</Text>
898898
</View>
899899
</View>

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -664,13 +664,21 @@ export const MessageInputProvider = <
664664
return;
665665
}
666666
if (file.state === FileState.UPLOADED || file.state === FileState.FINISHED) {
667-
attachments.push({
668-
asset_url: file.url,
669-
file_size: file.file.size,
670-
mime_type: file.file.type,
671-
title: file.file.name,
672-
type: 'file',
673-
} as Attachment<At>);
667+
if (file.file.type?.startsWith('image/')) {
668+
attachments.push({
669+
fallback: file.file.name,
670+
image_url: file.url,
671+
type: 'image',
672+
} as Attachment<At>);
673+
} else {
674+
attachments.push({
675+
asset_url: file.url,
676+
file_size: file.file.size,
677+
mime_type: file.file.type,
678+
title: file.file.name,
679+
type: 'file',
680+
} as Attachment<At>);
681+
}
674682
}
675683
}
676684

0 commit comments

Comments
 (0)