Fix 406 errors and realtime timeouts

This commit is contained in:
gpt-engineer-app[bot]
2025-10-03 17:12:41 +00:00
parent 2d0a45b5b0
commit 7308109af3

View File

@@ -48,21 +48,21 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
const changes: PhotoChange[] = []; const changes: PhotoChange[] = [];
try { try {
// Fetch photo submission with items // Fetch photo submission with items - use array query to avoid 406 errors
const { data: photoSubmission, error } = await supabase const { data: photoSubmissions, error } = await supabase
.from('photo_submissions') .from('photo_submissions')
.select(` .select(`
*, *,
items:photo_submission_items(*) items:photo_submission_items(*)
`) `)
.eq('submission_id', submissionId) .eq('submission_id', submissionId);
.maybeSingle();
if (error) { if (error) {
console.error('Error fetching photo submissions:', error); console.error('Error fetching photo submissions:', error);
return changes; return changes;
} }
const photoSubmission = photoSubmissions?.[0];
if (photoSubmission?.items && photoSubmission.items.length > 0) { if (photoSubmission?.items && photoSubmission.items.length > 0) {
// For now, treat all photos as additions // For now, treat all photos as additions
// TODO: Implement edit/delete detection by comparing with existing entity photos // TODO: Implement edit/delete detection by comparing with existing entity photos