Guard supabase.channel in aethexRealtimeService

cgen-77ab1761744c406d80570099654cb9df
This commit is contained in:
Builder.io 2025-09-28 00:23:02 +00:00
parent abaee59965
commit d7f628015d

View file

@ -567,13 +567,17 @@ export const aethexRealtimeService = {
userId: string, userId: string,
callback: (notification: any) => void, callback: (notification: any) => void,
) { ) {
return supabase const client: any = supabase as any;
if (!client || typeof client.channel !== "function") {
return { unsubscribe: () => {} } as any;
}
return client
.channel(`notifications:${userId}`) .channel(`notifications:${userId}`)
.on( .on(
"postgres_changes", "postgres_changes",
{ {
event: "INSERT", event: "INSERT",
schema: "public", schema: "public",
table: "notifications", table: "notifications",
filter: `user_id=eq.${userId}`, filter: `user_id=eq.${userId}`,
}, },
@ -583,7 +587,11 @@ export const aethexRealtimeService = {
}, },
subscribeToProjects(callback: (project: any) => void) { subscribeToProjects(callback: (project: any) => void) {
return supabase const client: any = supabase as any;
if (!client || typeof client.channel !== "function") {
return { unsubscribe: () => {} } as any;
}
return client
.channel("projects") .channel("projects")
.on( .on(
"postgres_changes", "postgres_changes",