From c1a8574d6919d37412c023be222ec201e15aebc3 Mon Sep 17 00:00:00 2001 From: xinyuwang-nus Date: Wed, 31 Jul 2024 16:21:23 +0800 Subject: [PATCH 1/3] exclude-lessons-not-current-week-from-today-schedule --- website/src/views/today/TodayContainer/TodayContainer.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/src/views/today/TodayContainer/TodayContainer.tsx b/website/src/views/today/TodayContainer/TodayContainer.tsx index ee03e6ec9c..1fd578aec1 100644 --- a/website/src/views/today/TodayContainer/TodayContainer.tsx +++ b/website/src/views/today/TodayContainer/TodayContainer.tsx @@ -8,6 +8,7 @@ import { differenceInCalendarDays, getHours, getMinutes, + getWeek, isSameDay, isWeekend, parseISO, @@ -261,6 +262,11 @@ export class TodayContainerComponent extends React.PureComponent { // of displaying inline inside the lesson, so the opened lesson is always null const openLesson = this.props.matchBreakpoint ? null : this.state.openLesson; + // Filter lessons to include only those where the current week is in the lesson's weeks array. + lessons = lessons.filter((lesson) => + lesson.weeks.toString().split(',').map(Number).includes(getWeek(date)) + ); + // If it is a day with no lessons if (!lessons.length) { return

You have no lessons today

; From a143a4fdd4b21256c2b19c94e5fd38f1ec9732cc Mon Sep 17 00:00:00 2001 From: xinyuwang-nus Date: Thu, 12 Sep 2024 18:22:21 +0800 Subject: [PATCH 2/3] Revert "exclude-lessons-not-current-week-from-today-schedule" This reverts commit c1a8574d6919d37412c023be222ec201e15aebc3. --- website/src/views/today/TodayContainer/TodayContainer.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/website/src/views/today/TodayContainer/TodayContainer.tsx b/website/src/views/today/TodayContainer/TodayContainer.tsx index 1fd578aec1..ee03e6ec9c 100644 --- a/website/src/views/today/TodayContainer/TodayContainer.tsx +++ b/website/src/views/today/TodayContainer/TodayContainer.tsx @@ -8,7 +8,6 @@ import { differenceInCalendarDays, getHours, getMinutes, - getWeek, isSameDay, isWeekend, parseISO, @@ -262,11 +261,6 @@ export class TodayContainerComponent extends React.PureComponent { // of displaying inline inside the lesson, so the opened lesson is always null const openLesson = this.props.matchBreakpoint ? null : this.state.openLesson; - // Filter lessons to include only those where the current week is in the lesson's weeks array. - lessons = lessons.filter((lesson) => - lesson.weeks.toString().split(',').map(Number).includes(getWeek(date)) - ); - // If it is a day with no lessons if (!lessons.length) { return

You have no lessons today

; From f5e88767e9e94bf19aeea00ed7c1535361d6a3d2 Mon Sep 17 00:00:00 2001 From: xinyuwang-nus Date: Thu, 12 Sep 2024 18:37:10 +0800 Subject: [PATCH 3/3] use sem2 weekInfo considering week before sem2 --- .../views/today/TodayContainer/TodayContainer.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/website/src/views/today/TodayContainer/TodayContainer.tsx b/website/src/views/today/TodayContainer/TodayContainer.tsx index ee03e6ec9c..f0f0abd7e1 100644 --- a/website/src/views/today/TodayContainer/TodayContainer.tsx +++ b/website/src/views/today/TodayContainer/TodayContainer.tsx @@ -347,8 +347,19 @@ export class TodayContainerComponent extends React.PureComponent { export const mapStateToProps = (state: StoreState, ownProps: OwnProps) => { const { modules } = state.moduleBank; - const lastDay = addDays(ownProps.currentTime, DAYS); - const weekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(lastDay); + + const lastDay = addDays(ownProps.currentTime, DAYS); // current date plus 7 days + const todayWeekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(new Date()); + const nextWeekInfo = NUSModerator.academicCalendar.getAcadWeekInfo(lastDay); + + var todaySemester = semesterNameMap[todayWeekInfo.sem]; + var nextWeekSemester = semesterNameMap[nextWeekInfo.sem]; + + // On week -1 of semester 2, the semester should be 2, not 1 + const weekBeforeSem2 = (todaySemester === 1 && nextWeekSemester === 2); + // If it's the week before semester 2, use sem2's week info, otherwise use current date's week info + const weekInfo = weekBeforeSem2 ? nextWeekInfo : todayWeekInfo; + const semester = semesterNameMap[weekInfo.sem]; const timetable = getSemesterTimetableLessons(state)(semester); const colors = getSemesterTimetableColors(state)(semester);