From 18ab43a7a3cbc0abd785c0ba3c9a47215d5d3ba0 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Mon, 24 Jul 2023 18:06:30 +0800 Subject: Attempt to display assignments in list order, but it's more complicated --- contents/ui/main.qml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'contents/ui/main.qml') diff --git a/contents/ui/main.qml b/contents/ui/main.qml index e685044..6f14c65 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -78,6 +78,13 @@ Item { normal: 0, finished: 0, } + let announcementLock = false + let assignmentIndices = { + important: 0, + normal: 0, + finished: 0, + } + let assignmentLock = false for (let course of courses) { const courseIdx = courseIndices[course.id] @@ -139,13 +146,29 @@ Item { finished: plasmoid.configuration.finishedAssignments.includes(assignment.id.toString()), } - if (!info.submitted || showSubmittedAssignments) { - if (info.important) { - assignmentsModel.insert(importantCount.assignments++, info) - } else { - assignmentsModel.append(info) + let idx = 0; + let endIdx = 0; + if (info.important) { + idx = assignmentIndices.important + endIdx = assignmentIndices.normal + assignmentIndices.normal++ + assignmentIndices.finished++ + } else if (!info.finished) { + idx = assignmentIndices.normal + endIdx = assignmentIndices.finished + assignmentIndices.finished++ + } else { + idx = assignmentIndices.normal + endIdx = assignmentsModel.count + } + + for (; idx < endIdx; idx++) { + const annc = assignmentsModel.get(idx) + if (courseIndices[course.id] < courseIndices[annc.courseId]) { + break } } + assignmentsModel.insert(idx, info) }) }) }) -- cgit v1.2.3