summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contents/ui/main.qml22
1 files changed, 18 insertions, 4 deletions
diff --git a/contents/ui/main.qml b/contents/ui/main.qml
index 9805065..468f449 100644
--- a/contents/ui/main.qml
+++ b/contents/ui/main.qml
@@ -49,23 +49,31 @@ Item {
announcementsModel.clear()
assignmentsModel.clear()
+ let importantCount = {announcements: 0, assignments: 0}
+
for (let course of courses) {
callApi(`/announcements?context_codes[]=course_${course[0]}`, 10, announcements => {
announcements.forEach(announcement => {
- announcementsModel.append({
+ const info = {
type: "announcement",
activityId: announcement.id,
course: course[1],
title: announcement.title,
url: announcement.html_url,
important: plasmoid.configuration.importantAnnouncements.includes(announcement.id.toString()),
- })
+ }
+
+ if (info.important) {
+ announcementsModel.insert(importantCount.announcements++, info) // place above unimportant ones
+ } else {
+ announcementsModel.append(info)
+ }
})
})
callApi(`/courses/${course[0]}/assignments`, 10, assignments => {
assignments.forEach(assignment => {
- assignmentsModel.append({
+ const info = {
type: "assignment",
activityId: assignment.id,
course: course[1],
@@ -73,7 +81,13 @@ Item {
dueAt: assignment.due_at,
url: assignment.html_url,
important: plasmoid.configuration.importantAssignments.includes(assignment.id.toString()),
- })
+ }
+
+ if (info.important) {
+ assignmentsModel.insert(importantCount.assignments++, info)
+ } else {
+ assignmentsModel.append(info)
+ }
})
})
}