这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions frontend/src/pages/GeneralSettings/Chats/ChatRow/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { useRef } from "react";
import truncate from "truncate";
import { X, Trash } from "@phosphor-icons/react";
import System from "@/models/system";
import ModalWrapper from "@/components/ModalWrapper";
import { useModal } from "@/hooks/useModal";

export default function ChatRow({ chat }) {
const rowRef = useRef(null);
export default function ChatRow({ chat, onDelete }) {
const {
isOpen: isPromptOpen,
openModal: openPromptModal,
Expand All @@ -25,16 +23,13 @@ export default function ChatRow({ chat }) {
)
)
return false;
rowRef?.current?.remove();
await System.deleteChat(chat.id);
onDelete(chat.id);
};

return (
<>
<tr
ref={rowRef}
className="bg-transparent text-white text-opacity-80 text-sm font-medium"
>
<tr className="bg-transparent text-white text-opacity-80 text-sm font-medium">
<td className="px-6 py-4 font-medium whitespace-nowrap text-white">
{chat.id}
</td>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/GeneralSettings/Chats/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ function ChatsContainer() {
setOffset(offset + 1);
};

const handleDeleteChat = (chatId) => {
setChats((prevChats) => prevChats.filter((chat) => chat.id !== chatId));
};

useEffect(() => {
async function fetchChats() {
const { chats: _chats, hasPages = false } = await System.chats(offset);
Expand Down Expand Up @@ -196,7 +200,9 @@ function ChatsContainer() {
</thead>
<tbody>
{!!chats &&
chats.map((chat) => <ChatRow key={chat.id} chat={chat} />)}
chats.map((chat) => (
<ChatRow key={chat.id} chat={chat} onDelete={handleDeleteChat} />
))}
</tbody>
</table>
<div className="flex w-full justify-between items-center">
Expand Down
11 changes: 3 additions & 8 deletions frontend/src/pages/GeneralSettings/EmbedChats/ChatRow/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useRef } from "react";
import truncate from "truncate";
import { X, Trash, LinkSimple } from "@phosphor-icons/react";
import ModalWrapper from "@/components/ModalWrapper";
import { useModal } from "@/hooks/useModal";
import paths from "@/utils/paths";
import Embed from "@/models/embed";

export default function ChatRow({ chat }) {
const rowRef = useRef(null);
export default function ChatRow({ chat, onDelete }) {
const {
isOpen: isPromptOpen,
openModal: openPromptModal,
Expand All @@ -26,16 +24,13 @@ export default function ChatRow({ chat }) {
)
)
return false;
rowRef?.current?.remove();
await Embed.deleteChat(chat.id);
onDelete(chat.id);
};

return (
<>
<tr
ref={rowRef}
className="bg-transparent text-white text-opacity-80 text-sm font-medium"
>
<tr className="bg-transparent text-white text-opacity-80 text-sm font-medium">
<td className="px-6 py-4 font-medium whitespace-nowrap text-white">
<a
href={paths.settings.embedSetup()}
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/GeneralSettings/EmbedChats/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ function ChatsContainer() {
setOffset(offset + 1);
};

const handleDeleteChat = (chatId) => {
setChats((prevChats) => prevChats.filter((chat) => chat.id !== chatId));
};

useEffect(() => {
async function fetchChats() {
const { chats: _chats, hasPages = false } = await Embed.chats(offset);
Expand Down Expand Up @@ -99,7 +103,9 @@ function ChatsContainer() {
</thead>
<tbody>
{!!chats &&
chats.map((chat) => <ChatRow key={chat.id} chat={chat} />)}
chats.map((chat) => (
<ChatRow key={chat.id} chat={chat} onDelete={handleDeleteChat} />
))}
</tbody>
</table>
<div className="flex w-full justify-between items-center">
Expand Down
2 changes: 1 addition & 1 deletion server/endpoints/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function systemEndpoints(app) {
try {
const { id } = request.params;
await WorkspaceChats.delete({ id: Number(id) });
response.sendStatus(200).end();
response.json({ success: true, error: null });
} catch (e) {
console.error(e);
response.sendStatus(500).end();
Expand Down