From 7b75375c06a52c6d1fd3b0abb1f1498b4bea9537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daphn=C3=A9=20Popin?= Date: Mon, 28 Oct 2024 17:51:53 +0100 Subject: [PATCH] Fix convo order in sidebar (#8278) --- front/lib/api/assistant/conversation.ts | 3 ++- front/lib/swr/conversations.ts | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) 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,