diff --git a/src/lib/components/chat/Placeholder/ChatList.svelte b/src/lib/components/chat/Placeholder/ChatList.svelte index 1e48298ec5..62869f7fc2 100644 --- a/src/lib/components/chat/Placeholder/ChatList.svelte +++ b/src/lib/components/chat/Placeholder/ChatList.svelte @@ -5,6 +5,8 @@ import dayjs from 'dayjs'; import localizedFormat from 'dayjs/plugin/localizedFormat'; import { getTimeRange } from '$lib/utils'; + import ChevronUp from '$lib/components/icons/ChevronUp.svelte'; + import ChevronDown from '$lib/components/icons/ChevronDown.svelte'; dayjs.extend(localizedFormat); @@ -20,15 +22,86 @@ ...chat, time_range: getTimeRange(chat.updated_at) })); + + chatList.sort((a, b) => { + if (direction === 'asc') { + return a[orderBy] > b[orderBy] ? 1 : -1; + } else { + return a[orderBy] < b[orderBy] ? 1 : -1; + } + }); } }; + const setSortKey = (key) => { + if (orderBy === key) { + direction = direction === 'asc' ? 'desc' : 'asc'; + } else { + orderBy = key; + direction = 'asc'; + } + + init(); + }; + + let orderBy = 'updated_at'; + let direction = 'desc'; // 'asc' or 'desc' + $: if (chats) { init(); } {#if chatList} + {#if chatList.length > 0} +
+ + +
+ {/if} +
{#if chatList.length === 0}