Guard Supabase realtime channel usage to prevent runtime errors
cgen-2bd999acc01d4c88aea6ab918f2ea3f9
This commit is contained in:
parent
d3d22d69ef
commit
abaee59965
1 changed files with 10 additions and 2 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue