Gracefully handle missing gallery_videos table before migration

This commit is contained in:
Ryan Salazar
2026-06-26 22:02:45 -04:00
parent 66e1df12b0
commit ff6db29cab

View File

@@ -117,11 +117,12 @@ export async function loadGallery(userId?: string | null): Promise<{
}
const supabase = createClient();
const [{ data: albums }, { data: photos }, { data: videos }] = await Promise.all([
const [{ data: albums }, { data: photos }, videoResult] = await Promise.all([
supabase.from("gallery_albums").select("*").eq("user_id", userId).order("sort_order"),
supabase.from("gallery_photos").select("*").eq("user_id", userId).order("sort_order"),
supabase.from("gallery_videos").select("*").eq("user_id", userId).order("sort_order"),
]);
const videos = videoResult.error ? [] : videoResult.data;
return {
albums: (albums as GalleryAlbum[])?.length