(Most likely) fix calendar not showing all events for the displayed dates
Some checks failed
E2E Tests / e2e (push) Has been cancelled
Tests and checks on push / run-checks-and-tests (push) Has been cancelled
Updates translation progress / update-translation-progress-issue (push) Has been cancelled

This commit is contained in:
Kalle 2025-11-15 11:09:42 +02:00
parent cf9c710469
commit 40c5f96cfe

View File

@ -1,4 +1,5 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import { add, sub } from "date-fns";
import type { UserPreferences } from "~/db/tables";
import { getUser } from "~/features/auth/core/user.server";
import { DAYS_SHOWN_AT_A_TIME } from "~/features/calendar/calendar-constants";
@ -27,12 +28,10 @@ export const loader = async (args: LoaderFunctionArgs) => {
).getTime()
: Date.now();
const twentyFourHoursAgo = date - 24 * 60 * 60 * 1000;
const fiveDaysFromNow = date + DAYS_SHOWN_AT_A_TIME * 24 * 60 * 60 * 1000;
const events = await CalendarRepository.findAllBetweenTwoTimestamps({
startTime: new Date(twentyFourHoursAgo),
endTime: new Date(fiveDaysFromNow),
// add a bit of tolerance to the timestamps to account for timezones
startTime: sub(new Date(date), { hours: 24 }),
endTime: add(new Date(date), { days: DAYS_SHOWN_AT_A_TIME + 1 }),
});
const filters = resolveFilters(args.request, user?.preferences);