Skip to content

Commit

Permalink
feat(chat): sort history with created at desc
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenZhang committed Dec 16, 2024
1 parent c9402b2 commit 7609505
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/views/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const currentMessageKey = 'local-message-id';
const messageIDPrefix = 'local-message-';
const localMessageStore = ref({});
const localMessageStoreKey = 'local-message-store';
const messageIDs = computed(() => {
const sortedMessageStore = computed(() => {
return Object.entries(localMessageStore.value)
.sort(([, a], [, b]) => b.created_at - a.created_at)
.reduce(
Expand Down Expand Up @@ -218,11 +218,11 @@ const setPromptForm = (data) => promptForm.value = data;
{{ $t('StartNewChat') }}
</a-button>
<a-list
v-if="Object.keys(localMessageStore).length > 0"
v-if="Object.keys(sortedMessageStore).length > 0"
:max-height="320"
>
<a-list-item
v-for="(data, messageID) in localMessageStore"
v-for="(data, messageID) in sortedMessageStore"
:key="messageID"
>
<template #extra>
Expand Down

0 comments on commit 7609505

Please sign in to comment.