diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-04-07 09:54:36 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-04-07 09:54:36 +0800 |
commit | d0943f4838e54f0639dccebc199d3453b11cf816 (patch) | |
tree | a858663f0a6074db948bc8d96e2b92f4fb72d2d6 /contents/ui | |
parent | c634f964ebc19e98a0a521ad13e244e712c25b7f (diff) |
Add Remove announcement button
Diffstat (limited to 'contents/ui')
-rw-r--r-- | contents/ui/AnnouncementView.qml | 6 | ||||
-rw-r--r-- | contents/ui/main.qml | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/contents/ui/AnnouncementView.qml b/contents/ui/AnnouncementView.qml index 5ce4d64..cba1d00 100644 --- a/contents/ui/AnnouncementView.qml +++ b/contents/ui/AnnouncementView.qml @@ -9,6 +9,7 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.extras 2.0 as PlasmaExtras RowLayout { + id: announcementView width: parent.width Layout.fillWidth: true @@ -40,6 +41,11 @@ RowLayout { PlasmaComponents3.ToolButton { icon.name: "delete" + onClicked: () => { + // avoid non-fatal TypeError due to announcementView.parent=null but .width=parent.width + announcementView.width = 0 + announcementsModel.remove(index) + } } } } diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 7241373..48d51b8 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -45,19 +45,22 @@ Item { // 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) { + activityStream.forEach((activity, index) => { if (activity.type == "Announcement") { announcementsModel.append({ + index: index, course: course[1], title: activity.title, url: activity.html_url }) } - } + }) }) } } |