Skip to content

Commit

Permalink
Upg: do not fetch useless participant columns for conversations and s…
Browse files Browse the repository at this point in the history
…ort client side (#8262)
  • Loading branch information
Fraggle authored Oct 26, 2024
1 parent 7e87f25 commit 5a67e24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion front/lib/api/assistant/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export async function getUserConversations(
}

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

const conversations = participations.reduce<ConversationWithoutContentType[]>(
Expand Down
6 changes: 5 additions & 1 deletion front/lib/swr/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 @@ -58,7 +59,10 @@ export function useConversations({ workspaceId }: { workspaceId: string }) {
);

return {
conversations: useMemo(() => (data ? data.conversations : []), [data]),
conversations: useMemo(
() => (data ? _.sortBy(data.conversations, "createdAt").reverse() : []),
[data]
),
isConversationsLoading: !error && !data,
isConversationsError: error,
mutateConversations: mutate,
Expand Down

0 comments on commit 5a67e24

Please sign in to comment.