Compare commits

..

2 Commits

Author SHA1 Message Date
litongjava
311f0e0879 fix bug: file 2025-02-03 01:27:27 -10:00
litongjava
3558dc2ed2 fetch chats with userid 2025-02-03 00:17:55 -10:00
4 changed files with 15 additions and 15 deletions

View File

@@ -20,8 +20,8 @@ const Page = () => {
useEffect(() => { useEffect(() => {
const fetchChats = async () => { const fetchChats = async () => {
setLoading(true); setLoading(true);
let userId = localStorage.getItem("userId");
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats`, { const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats?userId=` + userId, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -65,14 +65,14 @@ const Page = () => {
</div> </div>
<hr className="border-t border-[#2B2C2C] my-4 w-full"/> <hr className="border-t border-[#2B2C2C] my-4 w-full"/>
</div> </div>
{chats.length === 0 && ( {chats && chats.length === 0 && (
<div className="flex flex-row items-center justify-center min-h-screen"> <div className="flex flex-row items-center justify-center min-h-screen">
<p className="text-black/70 dark:text-white/70 text-sm"> <p className="text-black/70 dark:text-white/70 text-sm">
No chats found. No chats found.
</p> </p>
</div> </div>
)} )}
{chats.length > 0 && ( {chats && chats.length > 0 && (
<div className="flex flex-col pb-20 lg:pb-2"> <div className="flex flex-col pb-20 lg:pb-2">
{chats.map((chat, i) => ( {chats.map((chat, i) => (
<div <div

View File

@@ -367,7 +367,7 @@ const loadMessages = async (
document.title = messages[0].content; document.title = messages[0].content;
const files = data.chat.files.map((file: any) => { const files = data.chat.files && data.chat.files.map((file: any) => {
return { return {
fileName: file.name, fileName: file.name,
fileExtension: file.name.split('.').pop(), fileExtension: file.name.split('.').pop(),
@@ -376,7 +376,7 @@ const loadMessages = async (
}); });
setFiles(files); setFiles(files);
setFileIds(files.map((file: File) => file.fileId)); setFileIds(files && files.map((file: File) => file.fileId));
setChatHistory(history); setChatHistory(history);
setFocusMode(data.chat.focusMode); setFocusMode(data.chat.focusMode);
@@ -525,7 +525,7 @@ const ChatWindow = ({id}: { id?: string }) => {
focusMode: focusMode, focusMode: focusMode,
copilotEnabled: copilotEnabled, copilotEnabled: copilotEnabled,
optimizationMode: optimizationMode, optimizationMode: optimizationMode,
history: [...chatHistory, ['human', message]], history: [],
}), }),
); );

View File

@@ -55,7 +55,7 @@ const AttachSmall = ({
<div className="flex flex-row items-center justify-between space-x-1 p-1"> <div className="flex flex-row items-center justify-between space-x-1 p-1">
<LoaderCircle size={20} className="text-sky-400 animate-spin" /> <LoaderCircle size={20} className="text-sky-400 animate-spin" />
</div> </div>
) : files.length > 0 ? ( ) : files && files.length > 0 ? (
<Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg"> <Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg">
<PopoverButton <PopoverButton
type="button" type="button"

View File

@@ -50,7 +50,7 @@ const focusModes = [
}, },
{ {
key: 'translator', key: 'translator',
title: 'Trasnlator', title: 'Translator',
description: 'Chat without searching the web', description: 'Chat without searching the web',
icon: ( icon: (
<SiGoogletranslate <SiGoogletranslate