This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-17 00:39:11 +02:00
1 parent caedcbae49
commit ed4cb358a0
5 files changed
+68 -31

No files matched your search

@@ -9,10 +9,6 @@
import { toast } from 'svelte-sonner';
import { goto, invalidate, invalidateAll } from '$app/navigation';
import { onMount, getContext, createEventDispatcher, tick } from 'svelte';
const i18n = getContext('i18n');
const dispatch = createEventDispatcher();
import {
archiveChatById,
cloneChatById,
@@ -35,7 +31,8 @@
currentChatPage,
tags,
selectedFolder,
activeChatIds
activeChatIds,
user
} from '$lib/stores';
import ChatMenu from './ChatMenu.svelte';
@@ -53,6 +50,10 @@
import { generateTitle } from '$lib/apis';
import { createMessagesList } from '$lib/utils';
const i18n = getContext('i18n');
const dispatch = createEventDispatcher();
export let className = '';
export let id;
@@ -143,6 +144,11 @@
};
const cloneChatHandler = async (id) => {
if (!($user?.role === 'admin' || ($user?.permissions?.chat?.import ?? true))) {
toast.error($i18n.t('Access prohibited'));
return;
}
const res = await cloneChatById(
localStorage.token,
id,
@@ -387,17 +387,19 @@
{/if}
</button>
<button
draggable="false"
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl w-full"
on:click={() => {
show = false;
cloneChatHandler();
}}
>
<DocumentDuplicate strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Clone')}</div>
</button>
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.import ?? true)}
<button
draggable="false"
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl w-full"
on:click={() => {
show = false;
cloneChatHandler();
}}
>
<DocumentDuplicate strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Clone')}</div>
</button>
{/if}
{#if chatId && $folders.length > 0}
<DropdownSub
@@ -161,6 +161,11 @@
return null;
});
if (!chat && item) {
if (!($user?.role === 'admin' || ($user?.permissions?.chat?.import ?? true))) {
toast.error($i18n.t('Access prohibited'));
return;
}
chat = await importChats(localStorage.token, [
{
chat: item.chat,