From 34306e77cf7913a135022f2775528b248f7b6935 Mon Sep 17 00:00:00 2001 From: SethBurkart123 Date: Fri, 29 Nov 2024 10:29:35 +1100 Subject: [PATCH] fix(studentInfo): some cases year may be undefined --- src/seqta/ui/AddBetterSEQTAElements.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/seqta/ui/AddBetterSEQTAElements.ts b/src/seqta/ui/AddBetterSEQTAElements.ts index 7edab9f3..ed5aa1d6 100644 --- a/src/seqta/ui/AddBetterSEQTAElements.ts +++ b/src/seqta/ui/AddBetterSEQTAElements.ts @@ -13,7 +13,11 @@ export async function AddBetterSEQTAElements() { document.documentElement.classList.add('dark'); } createHomeButton(); - await appendBackgroundToUI(); + try { + await appendBackgroundToUI(); + } catch (error) { + console.error('Error appending background to UI:', error); + } await handleUserInfo(); handleStudentData(); createNewsButton(); @@ -144,7 +148,7 @@ async function getUserInfo() { } async function updateStudentInfo(students: any) { - const info = await getUserInfo(); // You would need to implement this to fetch or pass the user info + const info = await getUserInfo(); var index = students.findIndex(function (person: any) { return ( person.firstname == info.userDesc.split(' ')[0] && @@ -167,7 +171,11 @@ async function updateStudentInfo(students: any) { } } } else { - houseelement.innerText = students[index].year; + try { + houseelement.innerText = students[index].year; + } catch(err) { + houseelement.innerText = 'N/A'; + } } }