Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-berries-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/pdf-worker': patch
---

Fixes broken chat transcript when there are more than one file per message
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,14 @@ export const exampleData: WorkerData = {
name: 'Christian Castro',
username: 'cristiano.castro',
},
files: [{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') }],
files: [
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
{ name: 'screenshot.png', buffer: Buffer.from(base64Image, 'base64') },
],
},
{
msg: 'Thank you, I am checking on that for you now.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ import { fontScales } from '@rocket.chat/fuselage-tokens/typography.json';
import type { PDFFile } from '../../../types/ChatTranscriptData';

const styles = StyleSheet.create({
container: {
marginTop: 8,
width: '100%',
},
file: {
color: colors.n700,
marginTop: 4,
marginBottom: 16,
flexDirection: 'column',
fontSize: fontScales.c1.fontSize,
width: '100%',
},
fileName: {
marginBottom: 6,
},
image: {
width: 400,
width: '100%',
maxHeight: 240,
objectFit: 'contain',
objectPosition: '0',
Expand All @@ -31,10 +39,10 @@ const styles = StyleSheet.create({
});

export const Files = ({ files, invalidMessage }: { files: PDFFile[]; invalidMessage: string }) => (
<View wrap={false}>
<View style={styles.container}>
{files?.map((file, index) => (
<View style={styles.file} key={index}>
<Text>{file.name}</Text>
<View style={styles.file} key={index} wrap>
<Text style={styles.fileName}>{file.name}</Text>
{file.buffer ? (
// Cache = false is required to avoid a bug in react-pdf
// Which causes the image to be duplicated when using buffers because of bad caching
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const processMessage = (message: PDFMessage) => {
};

const Message = ({ message, invalidFileMessage }: { message: PDFMessage; invalidFileMessage: string }) => (
<View style={styles.wrapper} wrap={!!message.quotes || messageLongerThanPage(message.msg)}>
<View style={styles.wrapper} wrap={!!message.quotes || messageLongerThanPage(message.msg) || (message.files && message.files.length > 0)}>
{message.divider && <Divider divider={message.divider} />}
<MessageHeader name={message.u.name || message.u.username} time={message.ts} />

Expand Down
Loading