Update item counts on all feeds
This commit is contained in:
parent
63777e0db2
commit
ef79ee4997
@ -42,8 +42,8 @@
|
|||||||
All ({{unread}})
|
All ({{unread}})
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-for="feed in feeds" :class="{strong: unreadCount(feed), 'alert': true, 'alert-success': selectedFeed == feed.FeedURL }" :data-feed="feed.FeedURL" v-on:click="loadFeed(feed.ID)">
|
<div v-for="feed in feeds" :class="{strong: unreadCounts[feed.ID], 'alert': true, 'alert-success': selectedFeed == feed.FeedURL }" :data-feed="feed.FeedURL" v-on:click="loadFeed(feed.ID)">
|
||||||
{{feed.Title}} ({{unreadCount(feed)}})
|
{{feed.Title}} ({{unreadCounts[feed.ID]}})
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
@ -124,6 +124,13 @@
|
|||||||
},
|
},
|
||||||
unread() {
|
unread() {
|
||||||
return this.items.filter(item => !item.Read).length;
|
return this.items.filter(item => !item.Read).length;
|
||||||
|
},
|
||||||
|
unreadCounts() {
|
||||||
|
return this.items.filter(item => !item.Read).reduce((acc, item) => {
|
||||||
|
if (!acc[item.FeedID]) acc[item.FeedID] = 0;
|
||||||
|
acc[item.FeedID]++;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -136,9 +143,6 @@
|
|||||||
document.body.classList.toggle('dark');
|
document.body.classList.toggle('dark');
|
||||||
document.body.classList.toggle('dark-grey');
|
document.body.classList.toggle('dark-grey');
|
||||||
},
|
},
|
||||||
unreadCount(feed) {
|
|
||||||
return this.items.filter(item => item.FeedID == feed.ID).length;
|
|
||||||
},
|
|
||||||
loadFeed(feed) {
|
loadFeed(feed) {
|
||||||
this.selectedItem = undefined;
|
this.selectedItem = undefined;
|
||||||
this.selectedFeed = feed;
|
this.selectedFeed = feed;
|
||||||
@ -187,20 +191,20 @@
|
|||||||
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 (confirm(`Are you sure you want to mark ${ids.length} items as read?`)) {
|
||||||
this.setBusy(true);
|
this.setBusy(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(res => res.json())
|
||||||
.then(items => this.items = items)
|
.then(items => this.items = items)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setBusy(false);
|
this.setBusy(false);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
this.setBusy(false);
|
this.setBusy(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addSite(url) {
|
addSite(url) {
|
||||||
|
Loading…
Reference in New Issue
Block a user