Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions desktop/src/features/workflows/ui/WorkflowsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { WorkflowDialog } from "@/features/workflows/ui/WorkflowDialog";
import type { Channel, Workflow } from "@/shared/api/types";
import {
deleteWorkflow,
getChannelsWorkflows,
getChannelWorkflows,
triggerWorkflow,
} from "@/shared/api/tauriWorkflows";
import { Button } from "@/shared/ui/button";
Expand Down Expand Up @@ -83,20 +83,17 @@ export function WorkflowsView({
const allWorkflowsQuery = useQuery({
queryKey: allWorkflowsQueryKey(channelIdKey),
queryFn: async () => {
// Single batched relay query for all member channels, then group by the
// channel_id each workflow carries — replaces the per-channel fanout.
const channelNameById = new Map(
memberChannels.map((channel) => [channel.id, channel.name]),
const channelWorkflows = await Promise.all(
memberChannels.map(async (channel) => ({
channel,
workflows: await getChannelWorkflows(channel.id),
})),
);
const workflows = await getChannelsWorkflows(channelIds);
const results: WorkflowWithChannel[] = [];
for (const workflow of workflows) {
results.push({
workflow,
channelName: workflow.channelId
? (channelNameById.get(workflow.channelId) ?? "")
: "",
});
for (const { channel, workflows } of channelWorkflows) {
for (const workflow of workflows) {
results.push({ workflow, channelName: channel.name });
}
}
return results;
},
Expand Down