Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

realtime: Add footer channel to www application (#36707)

Filipe Cabaço8c867d874d41
diff --git a/apps/www/components/Footer/index.tsx b/apps/www/components/Footer/index.tsx
index 68897bc40ee..21d5241eab2 100644
--- a/apps/www/components/Footer/index.tsx
+++ b/apps/www/components/Footer/index.tsx
@@ -1,15 +1,18 @@
import { CheckIcon } from '@heroicons/react/outline'
+import { REALTIME_CHANNEL_STATES } from '@supabase/supabase-js'
import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
-import { Badge, IconDiscord, IconGitHubSolid, IconTwitterX, IconYoutubeSolid, cn } from 'ui'
-import SectionContainer from '../Layouts/SectionContainer'
+import { useEffect } from 'react'
import * as supabaseLogoWordmarkDark from 'common/assets/images/supabase-logo-wordmark--dark.png'
import * as supabaseLogoWordmarkLight from 'common/assets/images/supabase-logo-wordmark--light.png'
import footerData from 'data/Footer'
+import { Badge, IconDiscord, IconGitHubSolid, IconTwitterX, IconYoutubeSolid, cn } from 'ui'
import { ThemeToggle } from 'ui-patterns/ThemeToggle'
+import supabase from '~/lib/supabase'
import useDarkLaunchWeeks from '../../hooks/useDarkLaunchWeeks'
+import SectionContainer from '../Layouts/SectionContainer'
interface Props {
className?: string
@@ -23,6 +26,24 @@ const Footer = (props: Props) => {
const isGAWeek = pathname.includes('/ga-week')
const forceDark = isDarkLaunchWeek
+ useEffect(() => {
+ const channel = supabase.channel('footer')
+ if (channel.state === REALTIME_CHANNEL_STATES.closed) {
+ channel.subscribe((status: string) => {
+ if (status == 'SUBSCRIBED') {
+ channel.send({
+ type: 'broadcast',
+ event: 'footer_subscribed',
+ payload: { ts: Date.now() },
+ })
+ }
+ })
+ }
+ return () => {
+ channel.unsubscribe()
+ }
+ }, [])
+
if (props.hideFooter) {
return null
}