Skip to content
Merged

Test #1666

Show file tree
Hide file tree
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
33 changes: 0 additions & 33 deletions app/api/artist/route.tsx

This file was deleted.

53 changes: 6 additions & 47 deletions components/TasksPage/TasksList.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { Tables } from "@/types/database.types";
import { Task } from "@/lib/tasks/getTasks";
import TaskCard from "@/components/VercelChat/tools/tasks/TaskCard";
import TaskSkeleton from "./TaskSkeleton";
import TaskDetailsDialog from "@/components/VercelChat/dialogs/tasks/TaskDetailsDialog";
import { useArtistProvider } from "@/providers/ArtistProvider";
import { useUserProvider } from "@/providers/UserProvder";
import { useMemo } from "react";
import { useQuery } from "@tanstack/react-query";

type AccountEmail = Tables<"account_emails">;

interface TasksListProps {
tasks: Task[];
Expand All @@ -18,45 +12,13 @@ interface TasksListProps {

const TasksList: React.FC<TasksListProps> = ({ tasks, isLoading, isError }) => {
const { userData } = useUserProvider();
const { selectedArtist } = useArtistProvider();

// Extract unique account IDs from tasks
const accountIds = useMemo(
() => [...new Set(tasks.map(task => task.account_id))],
[tasks]
);

// Batch fetch emails for all task owners
const { data: accountEmails = [] } = useQuery<AccountEmail[]>({
queryKey: ["task-owner-emails", accountIds],
queryFn: async () => {
if (accountIds.length === 0 || !userData) return [];
const params = new URLSearchParams();
accountIds.forEach(id => params.append("accountIds", id));
params.append("currentAccountId", userData.id);
if (selectedArtist) {
params.append("artistAccountId", selectedArtist.account_id);
}
const response = await fetch(`/api/account-emails?${params}`);
if (!response.ok) throw new Error("Failed to fetch emails");
return response.json();
},
enabled: accountIds.length > 0 && !!userData,
});

// Create lookup map for O(1) email access
const emailByAccountId = useMemo(() => {
const map = new Map<string, string>();
accountEmails.forEach(ae => {
if (ae.account_id && ae.email) {
map.set(ae.account_id, ae.email);
}
});
return map;
}, [accountEmails]);

if (isError) {
return <div className="text-sm text-red-600 dark:text-red-400">Failed to load tasks</div>;
return (
<div className="text-sm text-red-600 dark:text-red-400">
Failed to load tasks
</div>
);
}

if (isLoading || !userData) {
Expand Down Expand Up @@ -88,10 +50,7 @@ const TasksList: React.FC<TasksListProps> = ({ tasks, isLoading, isError }) => {
index !== tasks.length - 1 ? "border-b border-border " : ""
}
>
<TaskCard
task={task}
ownerEmail={emailByAccountId.get(task.account_id)}
/>
<TaskCard task={task} ownerEmail={task.owner_email ?? undefined} />
</div>
</TaskDetailsDialog>
))}
Expand Down
20 changes: 0 additions & 20 deletions hooks/useArtistInstruction.ts

This file was deleted.

23 changes: 0 additions & 23 deletions hooks/useArtistKnowledge.ts

This file was deleted.

12 changes: 0 additions & 12 deletions hooks/useSaveKnowledgeEdit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useArtistProvider } from "@/providers/ArtistProvider";
import getMimeFromPath from "@/lib/files/getMimeFromPath";
import { uploadFile } from "@/lib/arweave/uploadFile";
import { useQueryClient } from "@tanstack/react-query";
import { toast } from "react-toastify";

type UseSaveKnowledgeEditArgs = {
Expand All @@ -21,9 +20,7 @@ export const useSaveKnowledgeEdit = ({
bases,
setBases,
saveSetting,
selectedArtist,
} = useArtistProvider();
const queryClient = useQueryClient();

const handleSave = async () => {
const mime = getMimeFromPath(name || url);
Expand All @@ -50,15 +47,6 @@ export const useSaveKnowledgeEdit = ({
}
try {
await saveSetting(next);
const artistId = selectedArtist?.account_id;
if (artistId) {
await queryClient.invalidateQueries({
queryKey: ["artist-knowledge", artistId],
});
await queryClient.invalidateQueries({
queryKey: ["artist-knowledge-text"],
});
}
toast.success("Saved");
return true;
} catch {
Expand Down
13 changes: 0 additions & 13 deletions lib/getArtist.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion lib/tasks/getTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ScheduledAction = Tables<"scheduled_actions">;
export type Task = ScheduledAction & {
recent_runs?: TaskRunItem[];
upcoming?: string[];
owner_email?: string | null;
};

export interface GetTasksParams {
Expand All @@ -27,7 +28,7 @@ export interface GetTasksResponse {
*/
export async function getTasks(
accessToken: string,
params?: GetTasksParams
params?: GetTasksParams,
): Promise<Task[]> {
try {
const url = new URL(`${getClientApiBaseUrl()}/api/tasks`);
Expand Down
Loading