From 2ccaf6be6dc2e284fcaefbc852725568136db79d Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sun, 30 Nov 2025 16:57:46 -0500 Subject: [PATCH] =?UTF-8?q?=E2=AC=87=EF=B8=8F=20refactor:=20Improve=20Conv?= =?UTF-8?q?ersation=20JSON=20Export=20(#10726)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the export logic in the useExportConversation hook to use JSON.stringify without indentation, reducing file size for deeply nested exports. Additionally, ensured safe access to text content by providing a fallback for undefined values. --- .../src/hooks/Conversations/useExportConversation.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/client/src/hooks/Conversations/useExportConversation.ts b/client/src/hooks/Conversations/useExportConversation.ts index 899189e206..25758f54b0 100644 --- a/client/src/hooks/Conversations/useExportConversation.ts +++ b/client/src/hooks/Conversations/useExportConversation.ts @@ -103,7 +103,7 @@ export default function useExportConversation({ if (content.type === ContentTypes.TEXT) { // TEXT const textPart = content[ContentTypes.TEXT]; - const text = typeof textPart === 'string' ? textPart : textPart.value; + const text = typeof textPart === 'string' ? textPart : (textPart?.value ?? ''); return [sender, text]; } @@ -365,12 +365,8 @@ export default function useExportConversation({ data['messages'] = messages; } - exportFromJSON({ - data: data, - fileName: filename, - extension: 'json', - exportType: exportFromJSON.types.json, - }); + /** Use JSON.stringify without indentation to minimize file size for deeply nested recursive exports */ + download(JSON.stringify(data), `${filename}.json`, 'application/json'); }; const exportConversation = () => {