refac
This commit is contained in:
1 parent
1457f2dec8
commit
35f8bf97e3
5 files changed
+166
-140
No files matched your search
@@ -48,7 +48,12 @@
|
|||||||
deleteAllChats,
|
deleteAllChats,
|
||||||
getChatListBySearchText
|
getChatListBySearchText
|
||||||
} from '$lib/apis/chats';
|
} from '$lib/apis/chats';
|
||||||
import { createNewFolder, getFolders, getSharedFolders, updateFolderParentIdById } from '$lib/apis/folders';
|
import {
|
||||||
|
createNewFolder,
|
||||||
|
getFolders,
|
||||||
|
getSharedFolders,
|
||||||
|
updateFolderParentIdById
|
||||||
|
} from '$lib/apis/folders';
|
||||||
import { createNewNote, getPinnedNoteList, toggleNotePinnedStatusById } from '$lib/apis/notes';
|
import { createNewNote, getPinnedNoteList, toggleNotePinnedStatusById } from '$lib/apis/notes';
|
||||||
import { updateUserSettings } from '$lib/apis/users';
|
import { updateUserSettings } from '$lib/apis/users';
|
||||||
import { checkActiveChats } from '$lib/apis/tasks';
|
import { checkActiveChats } from '$lib/apis/tasks';
|
||||||
@@ -1421,9 +1426,9 @@
|
|||||||
folder_id: null,
|
folder_id: null,
|
||||||
created_at: item?.created_at ?? null,
|
created_at: item?.created_at ?? null,
|
||||||
updated_at: item?.updated_at ?? null
|
updated_at: item?.updated_at ?? null
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
console.log(chat);
|
console.log(chat);
|
||||||
|
|||||||
@@ -579,139 +579,139 @@
|
|||||||
|
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
{#if !readonly}
|
{#if !readonly}
|
||||||
<div
|
<div
|
||||||
id="sidebar-chat-item-menu"
|
id="sidebar-chat-item-menu"
|
||||||
class="
|
class="
|
||||||
{id === $chatId || confirmEdit
|
{id === $chatId || confirmEdit
|
||||||
? 'from-gray-100 dark:from-gray-900 selected'
|
? 'from-gray-100 dark:from-gray-900 selected'
|
||||||
: selected
|
: selected
|
||||||
? 'from-gray-100 dark:from-gray-950 selected'
|
? 'from-gray-100 dark:from-gray-950 selected'
|
||||||
: 'invisible group-hover:visible from-gray-100 dark:from-gray-950'}
|
: 'invisible group-hover:visible from-gray-100 dark:from-gray-950'}
|
||||||
absolute {className === 'pr-2'
|
absolute {className === 'pr-2'
|
||||||
? 'right-[8px]'
|
? 'right-[8px]'
|
||||||
: 'right-1'} top-[4px] py-1 pr-0.5 mr-1.5 pl-5 bg-linear-to-l from-80%
|
: 'right-1'} top-[4px] py-1 pr-0.5 mr-1.5 pl-5 bg-linear-to-l from-80%
|
||||||
|
|
||||||
to-transparent"
|
to-transparent"
|
||||||
on:mouseenter={(e) => {
|
on:mouseenter={(e) => {
|
||||||
mouseOver = true;
|
mouseOver = true;
|
||||||
}}
|
}}
|
||||||
on:mouseleave={(e) => {
|
on:mouseleave={(e) => {
|
||||||
mouseOver = false;
|
mouseOver = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#if confirmEdit}
|
{#if confirmEdit}
|
||||||
<div
|
<div
|
||||||
class="flex self-center items-center space-x-1.5 z-10 translate-y-[0.5px] -translate-x-[0.5px]"
|
class="flex self-center items-center space-x-1.5 z-10 translate-y-[0.5px] -translate-x-[0.5px]"
|
||||||
>
|
>
|
||||||
<Tooltip content={$i18n.t('Generate')}>
|
<Tooltip content={$i18n.t('Generate')}>
|
||||||
<button
|
<button
|
||||||
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
||||||
id="generate-title-button"
|
id="generate-title-button"
|
||||||
disabled={generating}
|
disabled={generating}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
generateTitleHandler();
|
generateTitleHandler();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Sparkles strokeWidth="2" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
{:else if shiftKey && mouseOver}
|
||||||
|
<div class=" flex items-center self-center space-x-1.5">
|
||||||
|
<Tooltip content={$i18n.t('Archive')} className="flex items-center">
|
||||||
|
<button
|
||||||
|
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
||||||
|
disabled={archiving}
|
||||||
|
on:click={() => {
|
||||||
|
archiveChatHandler(id);
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<ArchiveBox className="size-4 translate-y-[0.5px]" strokeWidth="2" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip content={$i18n.t('Delete')}>
|
||||||
|
<button
|
||||||
|
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
||||||
|
disabled={deleting}
|
||||||
|
on:click={() => {
|
||||||
|
deleteChatHandler(id);
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<GarbageBin strokeWidth="2" />
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex self-center z-10 items-end">
|
||||||
|
<ChatMenu
|
||||||
|
chatId={id}
|
||||||
|
cloneChatHandler={() => {
|
||||||
|
cloneChatHandler(id);
|
||||||
}}
|
}}
|
||||||
>
|
shareHandler={() => {
|
||||||
<Sparkles strokeWidth="2" />
|
showShareChatModal = true;
|
||||||
</button>
|
}}
|
||||||
</Tooltip>
|
{moveChatHandler}
|
||||||
</div>
|
archiveChatHandler={() => {
|
||||||
{:else if shiftKey && mouseOver}
|
|
||||||
<div class=" flex items-center self-center space-x-1.5">
|
|
||||||
<Tooltip content={$i18n.t('Archive')} className="flex items-center">
|
|
||||||
<button
|
|
||||||
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
|
||||||
disabled={archiving}
|
|
||||||
on:click={() => {
|
|
||||||
archiveChatHandler(id);
|
archiveChatHandler(id);
|
||||||
}}
|
}}
|
||||||
type="button"
|
{renameHandler}
|
||||||
>
|
deleteHandler={() => {
|
||||||
<ArchiveBox className="size-4 translate-y-[0.5px]" strokeWidth="2" />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip content={$i18n.t('Delete')}>
|
|
||||||
<button
|
|
||||||
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
|
|
||||||
disabled={deleting}
|
|
||||||
on:click={() => {
|
|
||||||
deleteChatHandler(id);
|
|
||||||
}}
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<GarbageBin strokeWidth="2" />
|
|
||||||
</button>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div class="flex self-center z-10 items-end">
|
|
||||||
<ChatMenu
|
|
||||||
chatId={id}
|
|
||||||
cloneChatHandler={() => {
|
|
||||||
cloneChatHandler(id);
|
|
||||||
}}
|
|
||||||
shareHandler={() => {
|
|
||||||
showShareChatModal = true;
|
|
||||||
}}
|
|
||||||
{moveChatHandler}
|
|
||||||
archiveChatHandler={() => {
|
|
||||||
archiveChatHandler(id);
|
|
||||||
}}
|
|
||||||
{renameHandler}
|
|
||||||
deleteHandler={() => {
|
|
||||||
showDeleteConfirm = true;
|
|
||||||
}}
|
|
||||||
onClose={() => {
|
|
||||||
dispatch('unselect');
|
|
||||||
}}
|
|
||||||
onPinChange={async () => {
|
|
||||||
dispatch('change');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-label="Chat Menu"
|
|
||||||
class=" self-center dark:hover:text-white transition m-0"
|
|
||||||
on:click={() => {
|
|
||||||
dispatch('select');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
fill="currentColor"
|
|
||||||
class="w-4 h-4"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M2 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM6.5 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM12.5 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</ChatMenu>
|
|
||||||
|
|
||||||
{#if id === $chatId}
|
|
||||||
<!-- Shortcut support using "delete-chat-button" id -->
|
|
||||||
<button
|
|
||||||
id="delete-chat-button"
|
|
||||||
class="hidden"
|
|
||||||
on:click={() => {
|
|
||||||
showDeleteConfirm = true;
|
showDeleteConfirm = true;
|
||||||
}}
|
}}
|
||||||
|
onClose={() => {
|
||||||
|
dispatch('unselect');
|
||||||
|
}}
|
||||||
|
onPinChange={async () => {
|
||||||
|
dispatch('change');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<button
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
aria-label="Chat Menu"
|
||||||
viewBox="0 0 16 16"
|
class=" self-center dark:hover:text-white transition m-0"
|
||||||
fill="currentColor"
|
on:click={() => {
|
||||||
class="w-4 h-4"
|
dispatch('select');
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<path
|
<svg
|
||||||
d="M2 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM6.5 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM12.5 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
/>
|
viewBox="0 0 16 16"
|
||||||
</svg>
|
fill="currentColor"
|
||||||
</button>
|
class="w-4 h-4"
|
||||||
{/if}
|
>
|
||||||
</div>
|
<path
|
||||||
{/if}
|
d="M2 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM6.5 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM12.5 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"
|
||||||
</div>
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</ChatMenu>
|
||||||
|
|
||||||
|
{#if id === $chatId}
|
||||||
|
<!-- Shortcut support using "delete-chat-button" id -->
|
||||||
|
<button
|
||||||
|
id="delete-chat-button"
|
||||||
|
class="hidden"
|
||||||
|
on:click={() => {
|
||||||
|
showDeleteConfirm = true;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
fill="currentColor"
|
||||||
|
class="w-4 h-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M2 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM6.5 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM12.5 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -83,8 +83,19 @@
|
|||||||
onShare();
|
onShare();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
<svg
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.935-2.186 2.25 2.25 0 0 0-3.935 2.186Z" />
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-4"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.935-2.186 2.25 2.25 0 0 0-3.935 2.186Z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="flex items-center">{$i18n.t('Share')}</div>
|
<div class="flex items-center">{$i18n.t('Share')}</div>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -511,7 +511,7 @@
|
|||||||
</DragGhost>
|
</DragGhost>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div bind:this={folderElement} class="relative {className}" draggable="{!folders[folderId]?.shared}">
|
<div bind:this={folderElement} class="relative {className}" draggable={!folders[folderId]?.shared}>
|
||||||
{#if draggedOver}
|
{#if draggedOver}
|
||||||
<div
|
<div
|
||||||
class="absolute top-0 left-0 w-full h-full rounded-xs bg-gray-100/50 dark:bg-gray-700/20 bg-opacity-50 dark:bg-opacity-10 z-50 pointer-events-none touch-none"
|
class="absolute top-0 left-0 w-full h-full rounded-xs bg-gray-100/50 dark:bg-gray-700/20 bg-opacity-50 dark:bg-opacity-10 z-50 pointer-events-none touch-none"
|
||||||
|
|||||||
@@ -53,9 +53,7 @@
|
|||||||
|
|
||||||
<div class={className}>
|
<div class={className}>
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<div
|
<div class="w-full group">
|
||||||
class="w-full group"
|
|
||||||
>
|
|
||||||
<button
|
<button
|
||||||
class="w-full py-1 flex items-center gap-1 text-xs text-left font-medium
|
class="w-full py-1 flex items-center gap-1 text-xs text-left font-medium
|
||||||
text-gray-600 dark:text-gray-400
|
text-gray-600 dark:text-gray-400
|
||||||
@@ -85,9 +83,24 @@
|
|||||||
|
|
||||||
{#if !isWritable}
|
{#if !isWritable}
|
||||||
<div class="shrink-0 text-[10px] text-gray-400 dark:text-gray-600" title="Read only">
|
<div class="shrink-0 text-[10px] text-gray-400 dark:text-gray-600" title="Read only">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-3">
|
<svg
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-3"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -115,10 +128,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#each children as child (child.id)}
|
{#each children as child (child.id)}
|
||||||
<svelte:self
|
<svelte:self folder={child} {allSharedFolders} />
|
||||||
folder={child}
|
|
||||||
{allSharedFolders}
|
|
||||||
/>
|
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#if chats.length === 0 && children.length === 0}
|
{#if chats.length === 0 && children.length === 0}
|
||||||
|
|||||||
Reference in new issue
Block a user