Skip to content

Commit

Permalink
Fix convo order in sidebar (#8278)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph authored Oct 28, 2024
1 parent b9cb385 commit 7b75375
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 2 additions & 1 deletion front/lib/api/assistant/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export async function getUserConversations(
}

const participations = await ConversationParticipant.findAll({
attributes: [],
attributes: ["userId", "createdAt"],
where: {
userId: user.id,
action: "posted",
Expand All @@ -241,6 +241,7 @@ export async function getUserConversations(
required: true,
},
],
order: [["createdAt", "DESC"]],
});

const conversations = participations.reduce<ConversationWithoutContentType[]>(
Expand Down
6 changes: 1 addition & 5 deletions front/lib/swr/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7b75375

Please sign in to comment.