diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-04-06 16:14:31 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-04-06 16:14:31 +0800 |
commit | 23e689f43b56bc5e93d10bc395a28fbeca1a3c75 (patch) | |
tree | 6a72af2d23e10a3c0bfeb3d6fa718596c7a7fb31 /contents/ui/main.qml | |
parent | 4de22e12be00c0ed45831f73ab861a95573c0592 (diff) |
User can select courses to show on widget
Diffstat (limited to 'contents/ui/main.qml')
-rw-r--r-- | contents/ui/main.qml | 26 |
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 { |