summaryrefslogtreecommitdiff
path: root/contents/ui/main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'contents/ui/main.qml')
-rw-r--r--contents/ui/main.qml26
1 files changed, 15 insertions, 11 deletions
diff --git a/contents/ui/main.qml b/contents/ui/main.qml
index 09829a3..8d4beb2 100644
--- a/contents/ui/main.qml
+++ b/contents/ui/main.qml
@@ -39,18 +39,22 @@ Item {
}
function syncCanvas() {
- // Get all courses
- callApi("/courses", 20, courses => {
- for (let course of courses) {
- callApi(`/courses/${course.id}/activity_stream`, 10, activityStream => {
- for (let activity of activityStream) {
- if (activity.type == "Announcement") {
- announcementsModel.append({course: course.course_code, title: activity.title})
- }
+ let 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) }
+ )
+ announcementsModel.clear()
+ for (let course of courses) {
+ callApi(`/courses/${course[0]}/activity_stream`, 10, activityStream => {
+ // Get activity stream for each course
+ for (let activity of activityStream) {
+ if (activity.type == "Announcement") {
+ announcementsModel.append({course: course[1], title: activity.title})
}
- })
- }
- })
+ }
+ })
+ }
}
Timer {