From 0248517c6845a6c755d40c89d3d769ce7d60bd03 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 23 Jan 2025 15:59:58 +0000 Subject: Some more shit --- components/Sidebar.vue | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'components/Sidebar.vue') diff --git a/components/Sidebar.vue b/components/Sidebar.vue index 3d33586..bdbcd51 100644 --- a/components/Sidebar.vue +++ b/components/Sidebar.vue @@ -5,17 +5,27 @@ import { LucideClock, LucideRadio } from "lucide-vue-next"; const scheduleStore = useScheduleStore(); const errorStore = useErrorStore(); -const timeUntilConferenceStart = computed(() => { - if (!scheduleStore.schedule) { - return 0; - } +const timer = ref(); +const startsIn = ref(); +const ongoing = ref(false); +const finished = ref(false); - const now = new Date(); - const conferenceStart = new Date(scheduleStore.schedule.conference.start); - const diff = conferenceStart.getTime() - now.getTime(); +onMounted(() => { + startsIn.value = formatDistanceToNow(scheduleStore.getStartDate()); + ongoing.value = scheduleStore.isConferenceOngoing(); + finished.value = scheduleStore.isConferenceFinished(); - return diff; + timer.value = setInterval(() => { + startsIn.value = formatDistanceToNow(scheduleStore.getStartDate()); + ongoing.value = scheduleStore.isConferenceOngoing(); + finished.value = scheduleStore.isConferenceFinished(); + }, 1000); }); + +onBeforeUnmount(() => { + clearInterval(timer.value); +}); +