mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 15:08:44 -05:00
(Most likely) fix calendar not showing all events for the displayed dates
This commit is contained in:
parent
cf9c710469
commit
40c5f96cfe
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user