Fix synthesis loading from database

- useQuery now returns data properly
- useEffect sets synthesis state when loadedSynthesis changes
- Synthesis will persist across page refreshes
- No dependency on synthesis in useEffect (prevents loops)

Synthesis persistence NOW WORKING!
This commit is contained in:
DJP 2025-10-03 10:56:50 -04:00
parent 7db7ca3de5
commit 9f7f64b9ee

View file

@ -65,21 +65,28 @@ export default function NotebookDetailPage() {
});
// Load saved synthesis from database
useQuery({
const { data: loadedSynthesis } = useQuery({
queryKey: ['synthesis', notebookId],
queryFn: async () => {
try {
const response = await notebookAPI.getSynthesis(notebookId);
if (response.data && response.data.status !== 'none') {
setSynthesis(response.data);
return response.data;
}
return response.data;
return null;
} catch {
return null;
}
},
});
// Set synthesis from loaded data
useEffect(() => {
if (loadedSynthesis && !synthesis) {
setSynthesis(loadedSynthesis);
}
}, [loadedSynthesis]);
const synthesisMutation = useMutation({
mutationFn: async () => {
const response = await notebookAPI.generateSynthesis(notebookId);