Guard Supabase realtime channel usage to prevent runtime errors

cgen-2bd999acc01d4c88aea6ab918f2ea3f9
This commit is contained in:
Builder.io 2025-09-28 00:17:17 +00:00
parent d3d22d69ef
commit abaee59965

View file

@ -367,7 +367,11 @@ export const realtimeService = {
userId: string,
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}`)
.on(
"postgres_changes",
@ -383,7 +387,11 @@ export const realtimeService = {
},
subscribeToCommunityPosts(callback: (post: any) => void) {
return supabase
const client: any = supabase as any;
if (!client || typeof client.channel !== "function") {
return { unsubscribe: () => {} } as any;
}
return client
.channel("community_posts")
.on(
"postgres_changes",