mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 23:19:39 -05:00
Calendar: Fix showing past events last not working on Sunday Closes #1379
This commit is contained in:
parent
7342dd1667
commit
f23446659a
|
|
@ -25,6 +25,7 @@ import {
|
|||
databaseTimestampToDate,
|
||||
dateToThisWeeksMonday,
|
||||
dateToWeekNumber,
|
||||
dayToWeekStartsAtMondayDay,
|
||||
getWeekStartsAtMondayDay,
|
||||
weekNumberToDate,
|
||||
} from "~/utils/dates";
|
||||
|
|
@ -344,7 +345,9 @@ function EventsList({
|
|||
|
||||
const eventsGrouped = eventsGroupedByDay(events);
|
||||
if (sortPastEventsLast) {
|
||||
eventsGrouped.sort(pastEventsLast(data.currentDay));
|
||||
eventsGrouped.sort(
|
||||
pastEventsLast(dayToWeekStartsAtMondayDay(data.currentDay))
|
||||
);
|
||||
}
|
||||
|
||||
let dividerRendered = false;
|
||||
|
|
@ -354,7 +357,8 @@ function EventsList({
|
|||
const renderDivider =
|
||||
sortPastEventsLast &&
|
||||
!dividerRendered &&
|
||||
getWeekStartsAtMondayDay(daysDate) < data.currentDay;
|
||||
getWeekStartsAtMondayDay(daysDate) <
|
||||
dayToWeekStartsAtMondayDay(data.currentDay);
|
||||
if (renderDivider) {
|
||||
dividerRendered = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ export function dateToThisWeeksMonday(date: Date) {
|
|||
export function getWeekStartsAtMondayDay(date: Date) {
|
||||
const currentDay = date.getDay();
|
||||
|
||||
return currentDay === 0 ? 7 : currentDay;
|
||||
return dayToWeekStartsAtMondayDay(currentDay);
|
||||
}
|
||||
|
||||
export function dayToWeekStartsAtMondayDay(day: number) {
|
||||
return day === 0 ? 7 : day;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/71336659
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user