Skip to content

Commit df84b6a

Browse files
authored
fix: only query user tasks (#365)
1 parent 6cc9905 commit df84b6a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

apps/array/src/api/generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18276,6 +18276,7 @@ export namespace Endpoints {
1827618276
origin_product: string;
1827718277
repository: string;
1827818278
stage: string;
18279+
created_by: number;
1827918280
}>;
1828018281
path: { project_id: string };
1828118282
};

apps/array/src/api/posthogClient.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,18 @@ export class PostHogAPIClient {
6262
return data as Schemas.Team;
6363
}
6464

65-
async getTasks(repository?: string) {
65+
async getTasks(options?: { repository?: string; createdBy?: number }) {
6666
const teamId = await this.getTeamId();
6767
const params: Record<string, string | number> = {
6868
limit: 500,
6969
};
7070

71-
if (repository) {
72-
params.repository = repository;
71+
if (options?.repository) {
72+
params.repository = options.repository;
73+
}
74+
75+
if (options?.createdBy) {
76+
params.created_by = options.createdBy;
7377
}
7478

7579
const data = await this.api.get(`/api/projects/{project_id}/tasks/`, {

apps/array/src/renderer/features/tasks/hooks/useTasks.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useTaskExecutionStore } from "@features/task-detail/stores/taskExecutionStore";
22
import { useAuthenticatedMutation } from "@hooks/useAuthenticatedMutation";
33
import { useAuthenticatedQuery } from "@hooks/useAuthenticatedQuery";
4+
import { useMeQuery } from "@hooks/useMeQuery";
45
import { track } from "@renderer/lib/analytics";
56
import { logger } from "@renderer/lib/logger";
67
import type { Task } from "@shared/types";
@@ -13,17 +14,23 @@ const log = logger.scope("tasks");
1314
const taskKeys = {
1415
all: ["tasks"] as const,
1516
lists: () => [...taskKeys.all, "list"] as const,
16-
list: (filters?: { repository?: string }) =>
17+
list: (filters?: { repository?: string; createdBy?: number }) =>
1718
[...taskKeys.lists(), filters] as const,
1819
details: () => [...taskKeys.all, "detail"] as const,
1920
detail: (id: string) => [...taskKeys.details(), id] as const,
2021
};
2122

2223
export function useTasks(filters?: { repository?: string }) {
24+
const { data: currentUser } = useMeQuery();
25+
2326
return useAuthenticatedQuery(
24-
taskKeys.list(filters),
27+
taskKeys.list({ ...filters, createdBy: currentUser?.id }),
2528
(client) =>
26-
client.getTasks(filters?.repository) as unknown as Promise<Task[]>,
29+
client.getTasks({
30+
repository: filters?.repository,
31+
createdBy: currentUser?.id,
32+
}) as unknown as Promise<Task[]>,
33+
{ enabled: !!currentUser?.id },
2734
);
2835
}
2936

0 commit comments

Comments
 (0)