Skip to content

Commit

Permalink
Type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonderwhy-er committed Nov 23, 2024
1 parent 6e8aa04 commit fbea474
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/components/chat/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,12 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(

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');
Expand Down
1 change: 1 addition & 0 deletions app/components/chat/Chat.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ interface ChatProps {
storeMessageHistory: (messages: Message[]) => Promise<void>;
importChat: (description: string, messages: Message[]) => Promise<void>;
exportChat: () => void;
description?: string;
}

export const ChatImpl = memo(
Expand Down
2 changes: 1 addition & 1 deletion app/components/chat/ExportChatButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<WithTooltip tooltip="Export Chat">
<IconButton title="Export Chat" onClick={exportChat}>
Expand Down
6 changes: 5 additions & 1 deletion app/lib/persistence/useChatHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit fbea474

Please sign in to comment.