Guard supabase.channel in aethexRealtimeService
cgen-77ab1761744c406d80570099654cb9df
This commit is contained in:
parent
abaee59965
commit
d7f628015d
1 changed files with 11 additions and 3 deletions
|
|
@ -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",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue