diff --git a/front/lib/api/assistant/conversation.ts b/front/lib/api/assistant/conversation.ts index ef3498492813..0b79f0bd2c8a 100644 --- a/front/lib/api/assistant/conversation.ts +++ b/front/lib/api/assistant/conversation.ts @@ -229,7 +229,7 @@ export async function getUserConversations( } const participations = await ConversationParticipant.findAll({ - attributes: [], + attributes: ["userId", "createdAt"], where: { userId: user.id, action: "posted", @@ -241,6 +241,7 @@ export async function getUserConversations( required: true, }, ], + order: [["createdAt", "DESC"]], }); const conversations = participations.reduce( diff --git a/front/lib/swr/conversations.ts b/front/lib/swr/conversations.ts index 34f6ad790789..4c2c1e2e7158 100644 --- a/front/lib/swr/conversations.ts +++ b/front/lib/swr/conversations.ts @@ -5,7 +5,6 @@ import type { ConversationType, LightWorkspaceType, } from "@dust-tt/types"; -import _ from "lodash"; import { useCallback, useMemo } from "react"; import type { Fetcher } from "swr"; @@ -59,10 +58,7 @@ export function useConversations({ workspaceId }: { workspaceId: string }) { ); return { - conversations: useMemo( - () => (data ? _.sortBy(data.conversations, "createdAt").reverse() : []), - [data] - ), + conversations: useMemo(() => (data ? data.conversations : []), [data]), isConversationsLoading: !error && !data, isConversationsError: error, mutateConversations: mutate,