diff --git a/app/api/artist/route.tsx b/app/api/artist/route.tsx deleted file mode 100644 index 6c5072742..000000000 --- a/app/api/artist/route.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import supabase from "@/lib/supabase/serverClient"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const artistId = req.nextUrl.searchParams.get("artistId"); - - try { - const { data: account } = await supabase - .from("accounts") - .select("*, account_info(*), account_socials(*)") - .eq("id", artistId) - .single(); - if (!account) throw new Error("failed"); - - return Response.json( - { - artist: { - ...account.account_info[0], - ...account, - }, - }, - { status: 200 }, - ); - } catch (error) { - console.error(error); - const message = error instanceof Error ? error.message : "failed"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/components/TasksPage/TasksList.tsx b/components/TasksPage/TasksList.tsx index 9bd21c38c..2165ed3f7 100644 --- a/components/TasksPage/TasksList.tsx +++ b/components/TasksPage/TasksList.tsx @@ -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[]; @@ -18,45 +12,13 @@ interface TasksListProps { const TasksList: React.FC = ({ 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({ - 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(); - accountEmails.forEach(ae => { - if (ae.account_id && ae.email) { - map.set(ae.account_id, ae.email); - } - }); - return map; - }, [accountEmails]); if (isError) { - return
Failed to load tasks
; + return ( +
+ Failed to load tasks +
+ ); } if (isLoading || !userData) { @@ -88,10 +50,7 @@ const TasksList: React.FC = ({ tasks, isLoading, isError }) => { index !== tasks.length - 1 ? "border-b border-border " : "" } > - + ))} diff --git a/hooks/useArtistInstruction.ts b/hooks/useArtistInstruction.ts deleted file mode 100644 index 2e010642d..000000000 --- a/hooks/useArtistInstruction.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; - -export function useArtistInstruction(artistId?: string) { - return useQuery({ - queryKey: ["artist-instruction", artistId], - enabled: Boolean(artistId), - queryFn: async () => { - if (!artistId) return undefined; - const res = await fetch(`/api/artist?artistId=${encodeURIComponent(artistId)}`); - if (!res.ok) return undefined; - const json = await res.json(); - return json?.artist?.instruction || undefined; - }, - staleTime: 5 * 60 * 1000, - }); -} - -export default useArtistInstruction; - - diff --git a/hooks/useArtistKnowledge.ts b/hooks/useArtistKnowledge.ts deleted file mode 100644 index 262ab49ef..000000000 --- a/hooks/useArtistKnowledge.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { useQuery } from "@tanstack/react-query"; -import type { KnowledgeBaseEntry } from "@/lib/supabase/getArtistKnowledge"; - -export function useArtistKnowledge(artistId?: string) { - return useQuery({ - queryKey: ["artist-knowledge", artistId], - enabled: Boolean(artistId), - queryFn: async () => { - if (!artistId) return []; - const res = await fetch(`/api/artist?artistId=${encodeURIComponent(artistId)}`); - if (!res.ok) return []; - const json = await res.json(); - const knowledges: KnowledgeBaseEntry[] = - json?.artist?.account_info?.[0]?.knowledges || json?.artist?.knowledges || []; - return Array.isArray(knowledges) ? knowledges : []; - }, - staleTime: 5 * 60 * 1000, - }); -} - -export default useArtistKnowledge; - - diff --git a/hooks/useSaveKnowledgeEdit.ts b/hooks/useSaveKnowledgeEdit.ts index 9c035ef16..370a9a4a0 100644 --- a/hooks/useSaveKnowledgeEdit.ts +++ b/hooks/useSaveKnowledgeEdit.ts @@ -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 = { @@ -21,9 +20,7 @@ export const useSaveKnowledgeEdit = ({ bases, setBases, saveSetting, - selectedArtist, } = useArtistProvider(); - const queryClient = useQueryClient(); const handleSave = async () => { const mime = getMimeFromPath(name || url); @@ -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 { diff --git a/lib/getArtist.tsx b/lib/getArtist.tsx deleted file mode 100644 index eb984a9ed..000000000 --- a/lib/getArtist.tsx +++ /dev/null @@ -1,13 +0,0 @@ -const getArtist = async (artistId: string) => { - try { - const response = await fetch(`/api/artist?artistId=${artistId}`); - - const data = await response.json(); - - return data?.artist; - } catch (error) { - return { error }; - } -}; - -export default getArtist; diff --git a/lib/tasks/getTasks.ts b/lib/tasks/getTasks.ts index cbc6b3e28..de25477e1 100644 --- a/lib/tasks/getTasks.ts +++ b/lib/tasks/getTasks.ts @@ -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 { @@ -27,7 +28,7 @@ export interface GetTasksResponse { */ export async function getTasks( accessToken: string, - params?: GetTasksParams + params?: GetTasksParams, ): Promise { try { const url = new URL(`${getClientApiBaseUrl()}/api/tasks`);