Compare commits

...
2 Commits
Author SHA1 Message Date
ryan 1fe2d76973 Retain joins in hour on realtime update 2025-02-08 23:47:44 -08:00
ryan abe584b1c1 Oayout 2025-02-08 23:45:43 -08:00
3 changed files with 19 additions and 2 deletions
+4 -1
View File
@@ -26,7 +26,10 @@ export default function RealtimeDayPage({ initialDay }) {
const prevHours = day.hours; const prevHours = day.hours;
const newHours = prevHours.map((hour) => { const newHours = prevHours.map((hour) => {
if (hour.id === updatedHour.id) { if (hour.id === updatedHour.id) {
return updatedHour; return {
...updatedHour,
category: hour.category,
};
} }
return hour; return hour;
}); });
+1 -1
View File
@@ -45,7 +45,7 @@ export default function RootLayout({
{!hasEnvVars ? <EnvVarWarning /> : <HeaderAuth />} {!hasEnvVars ? <EnvVarWarning /> : <HeaderAuth />}
</div> </div>
</nav> </nav>
<div className="flex flex-col gap-20 max-w-5xl p-5"> <div className="flex flex-col gap-20 w-[40%] p-5">
{children} {children}
</div> </div>
+14
View File
@@ -0,0 +1,14 @@
'use client';
export default function
useEffect(() => {
const daysChannel = supabase.channel('days')
.on('postgres_changes', { event: 'UPDATE', schema: 'public', table: 'days' }, (payload) => {
setDay(payload.new);
}).subscribe();
return () => {
daysChannel.unsubscribe();
}
}, [supabase])