From fbea4744421cfa22608c6249fe17d90153c1cac8 Mon Sep 17 00:00:00 2001 From: eduardruzga Date: Sat, 23 Nov 2024 10:41:43 +0200 Subject: [PATCH] Type fixes --- app/components/chat/BaseChat.tsx | 8 ++++++-- app/components/chat/Chat.client.tsx | 1 + app/components/chat/ExportChatButton.tsx | 2 +- app/lib/persistence/useChatHistory.ts | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index d22d63b6c..ab67167b9 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -343,8 +343,12 @@ export const BaseChat = React.forwardRef( await importChat(data.description, data.messages); toast.success('Chat imported successfully'); - } catch (error) { - toast.error('Failed to parse chat file: ' + error.message); + } catch (error: unknown) { + if(error instanceof Error) { + toast.error('Failed to parse chat file: ' + error.message); + } else { + toast.error('Failed to parse chat file'); + } } }; reader.onerror = () => toast.error('Failed to read chat file'); diff --git a/app/components/chat/Chat.client.tsx b/app/components/chat/Chat.client.tsx index 4da080456..984182072 100644 --- a/app/components/chat/Chat.client.tsx +++ b/app/components/chat/Chat.client.tsx @@ -80,6 +80,7 @@ interface ChatProps { storeMessageHistory: (messages: Message[]) => Promise; importChat: (description: string, messages: Message[]) => Promise; exportChat: () => void; + description?: string; } export const ChatImpl = memo( diff --git a/app/components/chat/ExportChatButton.tsx b/app/components/chat/ExportChatButton.tsx index 5ee889ac9..8972eed1b 100644 --- a/app/components/chat/ExportChatButton.tsx +++ b/app/components/chat/ExportChatButton.tsx @@ -2,7 +2,7 @@ import WithTooltip from '~/components/ui/Tooltip'; import { IconButton } from '~/components/ui/IconButton'; import React from 'react'; -export const ExportChatButton = ({ exportChat }: { exportChat: () => void }) => { +export const ExportChatButton = ({ exportChat }: { exportChat?: () => void }) => { return ( diff --git a/app/lib/persistence/useChatHistory.ts b/app/lib/persistence/useChatHistory.ts index 779e59848..9daa61fdf 100644 --- a/app/lib/persistence/useChatHistory.ts +++ b/app/lib/persistence/useChatHistory.ts @@ -131,7 +131,11 @@ export function useChatHistory() { window.location.href = `/chat/${newId}`; toast.success('Chat imported successfully'); } catch (error) { - toast.error('Failed to import chat: ' + error.message); + if (error instanceof Error) { + toast.error('Failed to import chat: ' + error.message); + } else { + toast.error('Failed to import chat'); + } } }, exportChat: async (id = urlId) => {