Skip to content

Commit 35f8bf9

Browse files
committed
refac
1 parent 1457f2d commit 35f8bf9

5 files changed

Lines changed: 165 additions & 139 deletions

File tree

src/lib/components/layout/Sidebar.svelte

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
deleteAllChats,
4949
getChatListBySearchText
5050
} from '$lib/apis/chats';
51-
import { createNewFolder, getFolders, getSharedFolders, updateFolderParentIdById } from '$lib/apis/folders';
51+
import {
52+
createNewFolder,
53+
getFolders,
54+
getSharedFolders,
55+
updateFolderParentIdById
56+
} from '$lib/apis/folders';
5257
import { createNewNote, getPinnedNoteList, toggleNotePinnedStatusById } from '$lib/apis/notes';
5358
import { updateUserSettings } from '$lib/apis/users';
5459
import { checkActiveChats } from '$lib/apis/tasks';
@@ -1421,9 +1426,9 @@
14211426
folder_id: null,
14221427
created_at: item?.created_at ?? null,
14231428
updated_at: item?.updated_at ?? null
1424-
}
1425-
]);
1426-
}
1429+
}
1430+
]);
1431+
}
14271432

14281433
if (chat) {
14291434
console.log(chat);

src/lib/components/layout/Sidebar/ChatItem.svelte

Lines changed: 122 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -579,139 +579,139 @@
579579

580580
<!-- svelte-ignore a11y-no-static-element-interactions -->
581581
{#if !readonly}
582-
<div
583-
id="sidebar-chat-item-menu"
584-
class="
582+
<div
583+
id="sidebar-chat-item-menu"
584+
class="
585585
{id === $chatId || confirmEdit
586-
? 'from-gray-100 dark:from-gray-900 selected'
587-
: selected
588-
? 'from-gray-100 dark:from-gray-950 selected'
589-
: 'invisible group-hover:visible from-gray-100 dark:from-gray-950'}
586+
? 'from-gray-100 dark:from-gray-900 selected'
587+
: selected
588+
? 'from-gray-100 dark:from-gray-950 selected'
589+
: 'invisible group-hover:visible from-gray-100 dark:from-gray-950'}
590590
absolute {className === 'pr-2'
591-
? 'right-[8px]'
592-
: 'right-1'} top-[4px] py-1 pr-0.5 mr-1.5 pl-5 bg-linear-to-l from-80%
591+
? 'right-[8px]'
592+
: 'right-1'} top-[4px] py-1 pr-0.5 mr-1.5 pl-5 bg-linear-to-l from-80%
593593
594594
to-transparent"
595-
on:mouseenter={(e) => {
596-
mouseOver = true;
597-
}}
598-
on:mouseleave={(e) => {
599-
mouseOver = false;
600-
}}
601-
>
602-
{#if confirmEdit}
603-
<div
604-
class="flex self-center items-center space-x-1.5 z-10 translate-y-[0.5px] -translate-x-[0.5px]"
605-
>
606-
<Tooltip content={$i18n.t('Generate')}>
607-
<button
608-
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
609-
id="generate-title-button"
610-
disabled={generating}
611-
on:click={() => {
612-
generateTitleHandler();
595+
on:mouseenter={(e) => {
596+
mouseOver = true;
597+
}}
598+
on:mouseleave={(e) => {
599+
mouseOver = false;
600+
}}
601+
>
602+
{#if confirmEdit}
603+
<div
604+
class="flex self-center items-center space-x-1.5 z-10 translate-y-[0.5px] -translate-x-[0.5px]"
605+
>
606+
<Tooltip content={$i18n.t('Generate')}>
607+
<button
608+
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
609+
id="generate-title-button"
610+
disabled={generating}
611+
on:click={() => {
612+
generateTitleHandler();
613+
}}
614+
>
615+
<Sparkles strokeWidth="2" />
616+
</button>
617+
</Tooltip>
618+
</div>
619+
{:else if shiftKey && mouseOver}
620+
<div class=" flex items-center self-center space-x-1.5">
621+
<Tooltip content={$i18n.t('Archive')} className="flex items-center">
622+
<button
623+
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
624+
disabled={archiving}
625+
on:click={() => {
626+
archiveChatHandler(id);
627+
}}
628+
type="button"
629+
>
630+
<ArchiveBox className="size-4 translate-y-[0.5px]" strokeWidth="2" />
631+
</button>
632+
</Tooltip>
633+
634+
<Tooltip content={$i18n.t('Delete')}>
635+
<button
636+
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
637+
disabled={deleting}
638+
on:click={() => {
639+
deleteChatHandler(id);
640+
}}
641+
type="button"
642+
>
643+
<GarbageBin strokeWidth="2" />
644+
</button>
645+
</Tooltip>
646+
</div>
647+
{:else}
648+
<div class="flex self-center z-10 items-end">
649+
<ChatMenu
650+
chatId={id}
651+
cloneChatHandler={() => {
652+
cloneChatHandler(id);
613653
}}
614-
>
615-
<Sparkles strokeWidth="2" />
616-
</button>
617-
</Tooltip>
618-
</div>
619-
{:else if shiftKey && mouseOver}
620-
<div class=" flex items-center self-center space-x-1.5">
621-
<Tooltip content={$i18n.t('Archive')} className="flex items-center">
622-
<button
623-
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
624-
disabled={archiving}
625-
on:click={() => {
654+
shareHandler={() => {
655+
showShareChatModal = true;
656+
}}
657+
{moveChatHandler}
658+
archiveChatHandler={() => {
626659
archiveChatHandler(id);
627660
}}
628-
type="button"
629-
>
630-
<ArchiveBox className="size-4 translate-y-[0.5px]" strokeWidth="2" />
631-
</button>
632-
</Tooltip>
633-
634-
<Tooltip content={$i18n.t('Delete')}>
635-
<button
636-
class=" self-center dark:hover:text-white transition disabled:cursor-not-allowed"
637-
disabled={deleting}
638-
on:click={() => {
639-
deleteChatHandler(id);
661+
{renameHandler}
662+
deleteHandler={() => {
663+
showDeleteConfirm = true;
640664
}}
641-
type="button"
642-
>
643-
<GarbageBin strokeWidth="2" />
644-
</button>
645-
</Tooltip>
646-
</div>
647-
{:else}
648-
<div class="flex self-center z-10 items-end">
649-
<ChatMenu
650-
chatId={id}
651-
cloneChatHandler={() => {
652-
cloneChatHandler(id);
653-
}}
654-
shareHandler={() => {
655-
showShareChatModal = true;
656-
}}
657-
{moveChatHandler}
658-
archiveChatHandler={() => {
659-
archiveChatHandler(id);
660-
}}
661-
{renameHandler}
662-
deleteHandler={() => {
663-
showDeleteConfirm = true;
664-
}}
665-
onClose={() => {
666-
dispatch('unselect');
667-
}}
668-
onPinChange={async () => {
669-
dispatch('change');
670-
}}
671-
>
672-
<button
673-
aria-label="Chat Menu"
674-
class=" self-center dark:hover:text-white transition m-0"
675-
on:click={() => {
676-
dispatch('select');
665+
onClose={() => {
666+
dispatch('unselect');
677667
}}
678-
>
679-
<svg
680-
xmlns="http://www.w3.org/2000/svg"
681-
viewBox="0 0 16 16"
682-
fill="currentColor"
683-
class="w-4 h-4"
684-
>
685-
<path
686-
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"
687-
/>
688-
</svg>
689-
</button>
690-
</ChatMenu>
691-
692-
{#if id === $chatId}
693-
<!-- Shortcut support using "delete-chat-button" id -->
694-
<button
695-
id="delete-chat-button"
696-
class="hidden"
697-
on:click={() => {
698-
showDeleteConfirm = true;
668+
onPinChange={async () => {
669+
dispatch('change');
699670
}}
700671
>
701-
<svg
702-
xmlns="http://www.w3.org/2000/svg"
703-
viewBox="0 0 16 16"
704-
fill="currentColor"
705-
class="w-4 h-4"
672+
<button
673+
aria-label="Chat Menu"
674+
class=" self-center dark:hover:text-white transition m-0"
675+
on:click={() => {
676+
dispatch('select');
677+
}}
706678
>
707-
<path
708-
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"
709-
/>
710-
</svg>
711-
</button>
712-
{/if}
713-
</div>
714-
{/if}
715-
</div>
679+
<svg
680+
xmlns="http://www.w3.org/2000/svg"
681+
viewBox="0 0 16 16"
682+
fill="currentColor"
683+
class="w-4 h-4"
684+
>
685+
<path
686+
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"
687+
/>
688+
</svg>
689+
</button>
690+
</ChatMenu>
691+
692+
{#if id === $chatId}
693+
<!-- Shortcut support using "delete-chat-button" id -->
694+
<button
695+
id="delete-chat-button"
696+
class="hidden"
697+
on:click={() => {
698+
showDeleteConfirm = true;
699+
}}
700+
>
701+
<svg
702+
xmlns="http://www.w3.org/2000/svg"
703+
viewBox="0 0 16 16"
704+
fill="currentColor"
705+
class="w-4 h-4"
706+
>
707+
<path
708+
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"
709+
/>
710+
</svg>
711+
</button>
712+
{/if}
713+
</div>
714+
{/if}
715+
</div>
716716
{/if}
717717
</div>

src/lib/components/layout/Sidebar/Folders/FolderMenu.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,19 @@
8383
onShare();
8484
}}
8585
>
86-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
87-
<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" />
86+
<svg
87+
xmlns="http://www.w3.org/2000/svg"
88+
fill="none"
89+
viewBox="0 0 24 24"
90+
stroke-width="1.5"
91+
stroke="currentColor"
92+
class="size-4"
93+
>
94+
<path
95+
stroke-linecap="round"
96+
stroke-linejoin="round"
97+
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"
98+
/>
8899
</svg>
89100
<div class="flex items-center">{$i18n.t('Share')}</div>
90101
</button>

src/lib/components/layout/Sidebar/RecursiveFolder.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@
511511
</DragGhost>
512512
{/if}
513513
514-
<div bind:this={folderElement} class="relative {className}" draggable="{!folders[folderId]?.shared}">
514+
<div bind:this={folderElement} class="relative {className}" draggable={!folders[folderId]?.shared}>
515515
{#if draggedOver}
516516
<div
517517
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"

src/lib/components/layout/Sidebar/SharedFolderItem.svelte

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@
5353

5454
<div class={className}>
5555
<!-- svelte-ignore a11y-no-static-element-interactions -->
56-
<div
57-
class="w-full group"
58-
>
56+
<div class="w-full group">
5957
<button
6058
class="w-full py-1 flex items-center gap-1 text-xs text-left font-medium
6159
text-gray-600 dark:text-gray-400
@@ -85,9 +83,24 @@
8583

8684
{#if !isWritable}
8785
<div class="shrink-0 text-[10px] text-gray-400 dark:text-gray-600" title="Read only">
88-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-3">
89-
<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" />
90-
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
86+
<svg
87+
xmlns="http://www.w3.org/2000/svg"
88+
fill="none"
89+
viewBox="0 0 24 24"
90+
stroke-width="1.5"
91+
stroke="currentColor"
92+
class="size-3"
93+
>
94+
<path
95+
stroke-linecap="round"
96+
stroke-linejoin="round"
97+
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"
98+
/>
99+
<path
100+
stroke-linecap="round"
101+
stroke-linejoin="round"
102+
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
103+
/>
91104
</svg>
92105
</div>
93106
{/if}
@@ -115,10 +128,7 @@
115128
{/each}
116129

117130
{#each children as child (child.id)}
118-
<svelte:self
119-
folder={child}
120-
{allSharedFolders}
121-
/>
131+
<svelte:self folder={child} {allSharedFolders} />
122132
{/each}
123133

124134
{#if chats.length === 0 && children.length === 0}

0 commit comments

Comments
 (0)