summaryrefslogtreecommitdiff
path: root/contents/ui
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-04-09 12:13:39 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-04-09 12:13:39 +0800
commit41e83ceb0875f1ead3ff49452a4f6546bbf065d9 (patch)
tree6b73653d1ffcf8256bc649646664156c392ac046 /contents/ui
parent0bb237511d355731e332022ff96432b0b96d18d8 (diff)
Display important activities on top
Diffstat (limited to 'contents/ui')
-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)
+ }
})
})
}