feat: chat clone

This commit is contained in:
Timothy J. Baek
2024-05-31 10:30:42 -07:00
parent eb12d1e111
commit 7674229e3a
6 changed files with 125 additions and 26 deletions

View File

@@ -22,7 +22,8 @@
getChatListByTagName,
updateChatById,
getAllChatTags,
archiveChatById
archiveChatById,
cloneChatById
} from '$lib/apis/chats';
import { toast } from 'svelte-sonner';
import { fade, slide } from 'svelte/transition';
@@ -182,6 +183,18 @@
}
};
const cloneChatHandler = async (id) => {
const res = await cloneChatById(localStorage.token, id).catch((error) => {
toast.error(error);
return null;
});
if (res) {
goto(`/c/${res.id}`);
await chats.set(await getChatList(localStorage.token));
}
};
const saveSettings = async (updated) => {
await settings.set({ ...$settings, ...updated });
await updateUserSettings(localStorage.token, { ui: $settings });
@@ -601,6 +614,9 @@
<div class="flex self-center space-x-1 z-10">
<ChatMenu
chatId={chat.id}
cloneChatHandler={() => {
cloneChatHandler(chat.id);
}}
shareHandler={() => {
shareChatId = selectedChatId;
showShareChatModal = true;