Skip to content

Commit

Permalink
🐛 Fix timetable errors during semester break (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildmodeOne authored Aug 2, 2023
1 parent 2801b9e commit 27f9aeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rogue-thi-app/components/cards/TimetableCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ export default function TimetableCard () {
)
}))}
{(timetable && timetable.length === 0) &&
<ListGroup.Item>{t('timetable.text.noLectures')}</ListGroup.Item>
<ListGroup.Item>
{t('timetable.text.noLectures')}
</ListGroup.Item>
}
{(timetableError &&
<ListGroup.Item>{t('timetable.text.error')}</ListGroup.Item>)
}
<ListGroup.Item>{t('timetable.text.error')}</ListGroup.Item>
)}
</ListGroup>
</ReactPlaceholder>
</BaseCard>
Expand Down
9 changes: 9 additions & 0 deletions rogue-thi-app/lib/backend-utils/timetable-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ export function getTimetableGaps (timetable) {
export async function getFriendlyTimetable (date, detailed) {
const { timetable } = await API.getTimetable(date, detailed)

/**
* During the semester break, the API returns an null array ('[null]').
* To prevent errors for the room suggestions or the timetable view, we return an empty array.
*/
if (timetable.every(x => x === null)) {
console.error('API returned null array for timetable!')
return []
}

return timetable
.flatMap(day =>
Object.values(day.hours)
Expand Down

0 comments on commit 27f9aeb

Please sign in to comment.