From 85cd84b6a34c3890a1ea68d8682c8500e54bf8fe Mon Sep 17 00:00:00 2001 From: Dmitri Nasonov Date: Tue, 5 Nov 2024 00:00:13 +0000 Subject: [PATCH 1/2] A: Attempt to fix npes according to bug report --- .../ChatContent/Message/View/ContentView.tsx | 45 ++++++++++--------- src/types/chat.ts | 9 ++-- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/components/Chat/ChatContent/Message/View/ContentView.tsx b/src/components/Chat/ChatContent/Message/View/ContentView.tsx index bde062de1..035033784 100644 --- a/src/components/Chat/ChatContent/Message/View/ContentView.tsx +++ b/src/components/Chat/ChatContent/Message/View/ContentView.tsx @@ -23,7 +23,8 @@ import { ChatInterface, ContentInterface, ImageContentInterface, - TextContentInterface, + isImageContent, + isTextContent, } from '@type/chat'; import { codeLanguageSubset } from '@constants/chat'; @@ -106,9 +107,9 @@ const ContentView = memo( setChats(updatedChats); handleSubmit(); }; - + const currentTextContent = isTextContent(content[0]) ? content[0].text : ''; const handleCopy = () => { - navigator.clipboard.writeText((content[0] as TextContentInterface).text); + navigator.clipboard.writeText(currentTextContent); }; const handleImageClick = (imageUrl: string) => { @@ -118,7 +119,9 @@ const ContentView = memo( const handleCloseZoom = () => { setZoomedImage(null); }; - + const validImageContents = content + .slice(1) + .filter(isImageContent) as ImageContentInterface[]; return ( <>
@@ -146,27 +149,27 @@ const ContentView = memo( }} > {inlineLatex - ? preprocessLaTeX((content[0] as TextContentInterface).text) - : (content[0] as TextContentInterface).text} + ? preprocessLaTeX(currentTextContent) + : currentTextContent} ) : ( - - {(content[0] as TextContentInterface).text} - + {currentTextContent} )}
-
- {(content.slice(1) as ImageContentInterface[]).map((image, index) => ( -
- {`uploaded-${index}`} handleImageClick(image.image_url.url)} - /> -
- ))} -
+ {validImageContents.length > 0 && ( +
+ {validImageContents.map((image, index) => ( +
+ {`uploaded-${index}`} handleImageClick(image.image_url.url)} + /> +
+ ))} +
+ )} {zoomedImage && ( Date: Tue, 5 Nov 2024 00:00:58 +0000 Subject: [PATCH 2/2] version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b09aabd3..f5e348397 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "better-chatgpt", "private": true, - "version": "1.13.0", + "version": "1.14.0", "type": "module", "homepage": "./", "main": "electron/index.cjs",