web: add notification 'mark as seen' button

This commit is contained in:
Jens Langhammer
2021-01-16 19:09:03 +01:00
parent 36e8b1004c
commit 8acb9dde5f
5 changed files with 23 additions and 10 deletions

View File

@ -30,9 +30,12 @@ export class NotificationDrawer extends LitElement {
}
firstUpdated(): void {
Notification.list().then(r => {
Notification.list({
seen: false,
ordering: "-created"
}).then(r => {
this.notifications = r;
this.unread = r.results.filter((n) => !n.seen).length;
this.unread = r.results.length;
});
}
@ -63,6 +66,15 @@ export class NotificationDrawer extends LitElement {
${item.event?.action}
</h2>
</div>
<div class="pf-c-notification-drawer__list-item-action">
<button class="pf-c-dropdown__toggle pf-m-plain" type="button" @click=${() => {
Notification.markSeen(item.pk).then(() => {
this.firstUpdated();
});
}}>
<i class="fas fa-times"></i>
</button>
</div>
<p class="pf-c-notification-drawer__list-item-description">${item.body}</p>
<small class="pf-c-notification-drawer__list-item-timestamp">${age}</small>
</li>`;