Timothy Jaeryang Baek 3 tuần trước cách đây
mục cha
commit
025eef754f
1 tập tin đã thay đổi với 37 bổ sung37 xóa
  1. 37 37
      src/lib/components/chat/MessageInput/InputMenu/Chats.svelte

+ 37 - 37
src/lib/components/chat/MessageInput/InputMenu/Chats.svelte

@@ -43,14 +43,16 @@
 
 		items = [
 			...items,
-			...res.map((item) => {
-				return {
-					...item,
-					type: 'chat',
-					name: item.title,
-					description: dayjs(item.updated_at * 1000).fromNow()
-				};
-			})
+			...res
+				.filter((item) => item?.id !== $chatId)
+				.map((item) => {
+					return {
+						...item,
+						type: 'chat',
+						name: item.title,
+						description: dayjs(item.updated_at * 1000).fromNow()
+					};
+				})
 		];
 
 		itemsLoading = false;
@@ -71,35 +73,33 @@
 	{:else}
 		<div class="flex flex-col gap-0.5">
 			{#each items as item, idx}
-				{#if item?.id !== $chatId}
-					<button
-						class=" px-2.5 py-1 rounded-xl w-full text-left flex justify-between items-center text-sm {idx ===
-						selectedIdx
-							? ' bg-gray-50 dark:bg-gray-800 dark:text-gray-100 selected-command-option-button'
-							: ''}"
-						type="button"
-						on:click={() => {
-							onSelect(item);
-						}}
-						on:mousemove={() => {
-							selectedIdx = idx;
-						}}
-						on:mouseleave={() => {
-							if (idx === 0) {
-								selectedIdx = -1;
-							}
-						}}
-						data-selected={idx === selectedIdx}
-					>
-						<div class="text-black dark:text-gray-100 flex items-center gap-1.5">
-							<Tooltip content={item.description || decodeString(item?.name)} placement="top-start">
-								<div class="line-clamp-1 flex-1">
-									{decodeString(item?.name)}
-								</div>
-							</Tooltip>
-						</div>
-					</button>
-				{/if}
+				<button
+					class=" px-2.5 py-1 rounded-xl w-full text-left flex justify-between items-center text-sm {idx ===
+					selectedIdx
+						? ' bg-gray-50 dark:bg-gray-800 dark:text-gray-100 selected-command-option-button'
+						: ''}"
+					type="button"
+					on:click={() => {
+						onSelect(item);
+					}}
+					on:mousemove={() => {
+						selectedIdx = idx;
+					}}
+					on:mouseleave={() => {
+						if (idx === 0) {
+							selectedIdx = -1;
+						}
+					}}
+					data-selected={idx === selectedIdx}
+				>
+					<div class="text-black dark:text-gray-100 flex items-center gap-1.5">
+						<Tooltip content={item.description || decodeString(item?.name)} placement="top-start">
+							<div class="line-clamp-1 flex-1">
+								{decodeString(item?.name)}
+							</div>
+						</Tooltip>
+					</div>
+				</button>
 			{/each}
 
 			{#if !allItemsLoaded}