mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-09-14 21:41:33 +00:00
Compare commits
2 Commits
66b48146a3
...
311f0e0879
Author | SHA1 | Date | |
---|---|---|---|
|
311f0e0879 | ||
|
3558dc2ed2 |
@@ -1,10 +1,10 @@
|
||||
'use client';
|
||||
|
||||
import DeleteChat from '@/components/DeleteChat';
|
||||
import { cn, formatTimeDifference } from '@/lib/utils';
|
||||
import { BookOpenText, ClockIcon, Delete, ScanEye } from 'lucide-react';
|
||||
import {cn, formatTimeDifference} from '@/lib/utils';
|
||||
import {BookOpenText, ClockIcon, Delete, ScanEye} from 'lucide-react';
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {useEffect, useState} from 'react';
|
||||
|
||||
export interface Chat {
|
||||
id: string;
|
||||
@@ -20,8 +20,8 @@ const Page = () => {
|
||||
useEffect(() => {
|
||||
const fetchChats = async () => {
|
||||
setLoading(true);
|
||||
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats`, {
|
||||
let userId = localStorage.getItem("userId");
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats?userId=` + userId, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -60,19 +60,19 @@ const Page = () => {
|
||||
<div>
|
||||
<div className="flex flex-col pt-4">
|
||||
<div className="flex items-center">
|
||||
<BookOpenText />
|
||||
<BookOpenText/>
|
||||
<h1 className="text-3xl font-medium p-2">Library</h1>
|
||||
</div>
|
||||
<hr className="border-t border-[#2B2C2C] my-4 w-full" />
|
||||
<hr className="border-t border-[#2B2C2C] my-4 w-full"/>
|
||||
</div>
|
||||
{chats.length === 0 && (
|
||||
{chats && chats.length === 0 && (
|
||||
<div className="flex flex-row items-center justify-center min-h-screen">
|
||||
<p className="text-black/70 dark:text-white/70 text-sm">
|
||||
No chats found.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{chats.length > 0 && (
|
||||
{chats && chats.length > 0 && (
|
||||
<div className="flex flex-col pb-20 lg:pb-2">
|
||||
{chats.map((chat, i) => (
|
||||
<div
|
||||
@@ -92,7 +92,7 @@ const Page = () => {
|
||||
</Link>
|
||||
<div className="flex flex-row items-center justify-between w-full">
|
||||
<div className="flex flex-row items-center space-x-1 lg:space-x-1.5 text-black/70 dark:text-white/70">
|
||||
<ClockIcon size={15} />
|
||||
<ClockIcon size={15}/>
|
||||
<p className="text-xs">
|
||||
{formatTimeDifference(new Date(), chat.createdAt)} Ago
|
||||
</p>
|
||||
|
@@ -367,7 +367,7 @@ const loadMessages = async (
|
||||
|
||||
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 {
|
||||
fileName: file.name,
|
||||
fileExtension: file.name.split('.').pop(),
|
||||
@@ -376,7 +376,7 @@ const loadMessages = async (
|
||||
});
|
||||
|
||||
setFiles(files);
|
||||
setFileIds(files.map((file: File) => file.fileId));
|
||||
setFileIds(files && files.map((file: File) => file.fileId));
|
||||
|
||||
setChatHistory(history);
|
||||
setFocusMode(data.chat.focusMode);
|
||||
@@ -525,7 +525,7 @@ const ChatWindow = ({id}: { id?: string }) => {
|
||||
focusMode: focusMode,
|
||||
copilotEnabled: copilotEnabled,
|
||||
optimizationMode: optimizationMode,
|
||||
history: [...chatHistory, ['human', message]],
|
||||
history: [],
|
||||
}),
|
||||
);
|
||||
|
||||
|
@@ -55,7 +55,7 @@ const AttachSmall = ({
|
||||
<div className="flex flex-row items-center justify-between space-x-1 p-1">
|
||||
<LoaderCircle size={20} className="text-sky-400 animate-spin" />
|
||||
</div>
|
||||
) : files.length > 0 ? (
|
||||
) : files && files.length > 0 ? (
|
||||
<Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg">
|
||||
<PopoverButton
|
||||
type="button"
|
||||
|
@@ -50,7 +50,7 @@ const focusModes = [
|
||||
},
|
||||
{
|
||||
key: 'translator',
|
||||
title: 'Trasnlator',
|
||||
title: 'Translator',
|
||||
description: 'Chat without searching the web',
|
||||
icon: (
|
||||
<SiGoogletranslate
|
||||
|
Reference in New Issue
Block a user