Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch dayBoundary and forward updates to Qalendar. #389

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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