Fix: calendar timezone performance improvements (#2668)

This commit is contained in:
Denis Papec 2024-01-17 23:00:51 +00:00 committed by GitHub
parent 93dc6db4ef
commit 72efd9a08d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 28 deletions

View file

@ -3,16 +3,14 @@ import { DateTime, Info } from "luxon";
import classNames from "classnames";
import { useTranslation } from "next-i18next";
import Event, { compareDateTimezoneAware } from "./event";
import Event, { compareDateTimezone } from "./event";
const cellStyle = "relative w-10 flex items-center justify-center flex-col";
const monthButton = "pl-6 pr-6 ml-2 mr-2 hover:bg-theme-100/20 dark:hover:bg-white/5 rounded-md cursor-pointer";
export function Day({ weekNumber, weekday, events, colorVariants, showDate, setShowDate }) {
const currentDate = DateTime.now();
export function Day({ weekNumber, weekday, events, colorVariants, showDate, setShowDate, currentDate }) {
const cellDate = showDate.set({ weekday, weekNumber }).startOf("day");
const filteredEvents = events?.filter((event) => compareDateTimezoneAware(cellDate, event));
const filteredEvents = events?.filter((event) => compareDateTimezone(cellDate, event));
const dayStyles = (displayDate) => {
let style = "h-9 ";
@ -77,10 +75,9 @@ const dayInWeekId = {
sunday: 7,
};
export default function Monthly({ service, colorVariants, events, showDate, setShowDate }) {
export default function Monthly({ service, colorVariants, events, showDate, setShowDate, currentDate }) {
const { widget } = service;
const { i18n } = useTranslation();
const currentDate = DateTime.now().setLocale(i18n.language).startOf("day");
const dayNames = Info.weekdays("short", { locale: i18n.language });
@ -164,6 +161,7 @@ export default function Monthly({ service, colorVariants, events, showDate, setS
colorVariants={colorVariants}
showDate={showDate}
setShowDate={setShowDate}
currentDate={currentDate}
/>
)),
)}
@ -171,7 +169,7 @@ export default function Monthly({ service, colorVariants, events, showDate, setS
<div className="flex flex-col">
{eventsArray
?.filter((event) => compareDateTimezoneAware(showDate, event))
?.filter((event) => compareDateTimezone(showDate, event))
.slice(0, widget?.maxEvents ?? 10)
.map((event) => (
<Event
@ -179,7 +177,7 @@ export default function Monthly({ service, colorVariants, events, showDate, setS
event={event}
colorVariants={colorVariants}
showDateColumn={widget?.showTime ?? false}
showTime={widget?.showTime && compareDateTimezoneAware(showDate, event)}
showTime={widget?.showTime && compareDateTimezone(showDate, event)}
/>
))}
</div>