Skip to content

Commit

Permalink
Watch dayBoundary and forward updates to Qalendar. (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn authored and jdbass committed May 17, 2024
1 parent 38e65f7 commit 428ce4d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions frontend/src/components/CalendarQalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,16 @@ const calendarEvents = computed(() => {
* @type {ComputedRef<{start, end}>}
*/
const dayBoundary = computed(() => {
let startHour = 99;
let endHour = 0;
if (calendarEvents?.value.length === 0) {
return {
start: 0,
end: 24,
};
}
let startHour = 99;
let endHour = 0;
calendarEvents.value.forEach((event) => {
// Calculate start/end hours
startHour = Math.min(startHour, dj(event.time.start).hour());
Expand Down Expand Up @@ -322,7 +322,23 @@ if (locale) {
* Qalendar's selectedDate is only set on init and never updated. So we have to poke at their internals...
*/
watch(currentDate, () => onCurrentDateChange(currentDate.value));
/**
* We need to update the Time object manually when we get new dayBoundaries. (But only if they're not the default val)
*/
watch(dayBoundary, () => {
// Don't try to update qalendar if we don't have a valid reference!
if (!qalendarRef?.value) {
return;
}
// Don't refresh with the default values
if (dayBoundary.value.start === 0 && dayBoundary.value.end === 24) {
return;
}
qalendarRef.value.time.DAY_START = dayBoundary.value.start * 100;
qalendarRef.value.time.DAY_END = dayBoundary.value.end * 100;
});
</script>
<template>
<div
Expand Down

0 comments on commit 428ce4d

Please sign in to comment.