Improve mark as read
This commit is contained in:
parent
4341529154
commit
57e2176e03
@ -203,14 +203,13 @@
|
|||||||
},
|
},
|
||||||
markAllRead() {
|
markAllRead() {
|
||||||
let ids = this.shownItems.filter(item => !item.Read).map(item => item.ID);
|
let ids = this.shownItems.filter(item => !item.Read).map(item => item.ID);
|
||||||
if (confirm(`Are you sure you want to mark ${ids.length} items as read?`)) {
|
if (ids.length > 0 && confirm(`Are you sure you want to mark ${ids.length} items as read?`)) {
|
||||||
this.setBusy(true);
|
this.setBusy(true);
|
||||||
|
this.shownItems.filter(item => !item.Read).forEach(item => item.Read = true)
|
||||||
fetch(
|
fetch(
|
||||||
`/api/read`,
|
`/api/read`,
|
||||||
{method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(ids)}
|
{method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(ids)}
|
||||||
)
|
)
|
||||||
.then(res => res.json())
|
|
||||||
.then(items => this.items = items)
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setBusy(false);
|
this.setBusy(false);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user