diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-04-09 16:49:05 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-04-09 16:49:05 +0800 |
commit | 5f740256b6bd01dd66fa6e54a5176bd88d68cf6e (patch) | |
tree | cafe08ad5e6be1d5fcbcb0c7b7c7d08e97b6fed8 /contents/ui | |
parent | fbadabe38b4611ecd373c88023fa3701bea827c9 (diff) |
Show full course code
Diffstat (limited to 'contents/ui')
-rw-r--r-- | contents/ui/main.qml | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 8568116..58e3faf 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -43,7 +43,10 @@ Item { const courses = plasmoid.configuration.courses.split("\n").map( // each line in the "courses" config consists of // a numeric course id, a space, and a course code - line => { return line.split(" ", 2) } + line => { + const spaceIndex = line.indexOf(" ") + return {id: line.slice(0, spaceIndex), code: line.slice(spaceIndex + 1)} + } ) const showSubmittedAssignments = plasmoid.configuration.showSubmittedAssignments @@ -54,12 +57,12 @@ Item { let importantCount = {announcements: 0, assignments: 0} for (let course of courses) { - callApi(`/announcements?context_codes[]=course_${course[0]}`, 10, announcements => { + callApi(`/announcements?context_codes[]=course_${course.id}`, 10, announcements => { announcements.forEach(announcement => { const info = { type: "announcement", activityId: announcement.id, - course: course[1], + course: course.code, title: announcement.title, url: announcement.html_url, important: plasmoid.configuration.importantAnnouncements.includes(announcement.id.toString()), @@ -73,12 +76,12 @@ Item { }) }) - callApi(`/courses/${course[0]}/assignments`, 10, assignments => { + callApi(`/courses/${course.id}/assignments`, 10, assignments => { assignments.forEach(assignment => { const info = { type: "assignment", activityId: assignment.id, - course: course[1], + course: course.code, title: assignment.name, dueAt: assignment.due_at, submitted: assignment.has_submitted_submissions, |