Added fix for calendar update channel

This commit is contained in:
Alexis
2025-03-05 20:21:33 +01:00
parent 1aa3350da3
commit d46da12745
5 changed files with 36 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { RealtimeChannel } from "@supabase/supabase-js"
import type { World } from "~/models/World";
import type { Calendar } from "~/models/CalendarConfig";
import type { Calendar, CalendarChannelPayload } from "~/models/CalendarConfig";
import { PhArrowBendDoubleUpLeft, PhGlobeHemisphereWest, PhPencil } from "@phosphor-icons/vue";
const supabase = useSupabaseClient()
@@ -40,9 +40,12 @@ let calendarChannel: RealtimeChannel
let worldChannel: RealtimeChannel
/** Handles calendar insertion realtime events */
function handleInsertedCalendar(newCalendar: Calendar) {
function handleInsertedCalendar(newCalendar: CalendarChannelPayload) {
if (!world.value) return
newCalendar.createdAt = newCalendar.created_at;
newCalendar.eventNb = [{ count: 0 }];
try {
world.value.data.calendars?.push(newCalendar)
} catch (err) {