summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contents/ui/main.qml13
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,