Feat/real time dashboard#2186
Open
Naveen-Boddepalli wants to merge 1 commit into
Open
Conversation
|
@Naveen-Boddepalli is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Owner
|
This PR has merge conflicts with Please:
git fetch origin
git rebase origin/main |
3dd759a to
890e471
Compare
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Supabase Realtime subscriptions to
StreakTracker,GoalTracker, andDashboardHeaderso dashboard widgets update live when underlying data changes — no manual refresh required. Includes a 60-second polling fallback for when the WebSocket connection is unavailable.Closes #2115
Type of Change
What Changed
src/hooks/useRealtimeSync.ts(new) — Shared hook that opens a Supabase Realtime channel for a given table and event list, tracks connection status, and falls back to polling (fallbackPollingMs, default 60 s) onCLOSED/CHANNEL_ERROR/TIMED_OUT. Uses a singleton Supabase client per tab and anonUpdateRefpattern to avoid stale closures without recreating the channel on re-renders.StreakTracker.tsx— Subscribes tostreak_freezesINSERT/DELETE; triggersfetchFreeze+fetchStreakon change. Shows pulsing greenLivebadge next to the "Commit Streaks" header when connected.GoalTracker.tsx— Subscribes togoalsINSERT/UPDATE/DELETE; triggersloadGoalson change. Shows pulsing greenLivebadge next to the "Goals" header when connected.DashboardHeader.tsx— ExtractsloadSettingsfrom auseEffectto auseCallback; subscribes tousersUPDATE; showsLivebadge inline with the "Synced" timestamp.How to Test
streak_freezes,goals, anduserstables in the Supabase dashboard (Database → Replication).pnpm devand sign in.Livebadge appears in the Goals header, Streak header, and next to the "Synced" timestamp in the dashboard header.Livebadge disappears and data still refreshes every 60 seconds.Expected result: All three widgets reflect changes made in another tab within 1–2 seconds when Live. No memory leaks (subscriptions are removed on unmount via the
useEffectcleanup).Screenshots
Live indicator — Goals
Live indicator — Streak Tracker
Cross-tab real-time update
Checklist
console.log, debug code, or commented-out blockspnpm lintpasses locallypnpm type-check)Additional Context
Required Supabase config: Realtime must be enabled for
streak_freezes,goals, andusersin the Supabase dashboard under Database → Replication. Without it the hook falls back to 60-second polling automatically — nothing breaks.No breaking changes — all existing fetch logic is preserved. Realtime is additive on top of it.
Contributed under GSSoC '26.