mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-28 21:18:54 +03:00
perf: Add mark all as read button in RssArticles view (#798)
This commit is contained in:
parent
b276004b28
commit
93d3fdc85a
2 changed files with 21 additions and 3 deletions
|
@ -190,6 +190,7 @@
|
||||||
"rss": {
|
"rss": {
|
||||||
"title": "RSS Articles",
|
"title": "RSS Articles",
|
||||||
"filterRead": "Unread articles only",
|
"filterRead": "Unread articles only",
|
||||||
|
"markAllAsRead": "Mark all as read",
|
||||||
"columnTitle": {
|
"columnTitle": {
|
||||||
"feedName": "Feed Name",
|
"feedName": "Feed Name",
|
||||||
"author": "Author",
|
"author": "Author",
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<v-data-table
|
<v-data-table
|
||||||
id="articlesTable"
|
id="articlesTable"
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:items="articles"
|
:items="filterUnread ? unreadArticles : articles"
|
||||||
:items-per-page="15"
|
:items-per-page="15"
|
||||||
:search="filter"
|
:search="filter"
|
||||||
:custom-filter="customFilter"
|
:custom-filter="customFilter"
|
||||||
|
@ -30,7 +30,16 @@
|
||||||
<template #top>
|
<template #top>
|
||||||
<div class="mx-4">
|
<div class="mx-4">
|
||||||
<v-text-field v-model="filter" :label="$t('filter')" />
|
<v-text-field v-model="filter" :label="$t('filter')" />
|
||||||
<v-checkbox v-model="filterUnread" :label="$t('modals.rss.filterRead')" hide-details />
|
<v-row>
|
||||||
|
<v-col>
|
||||||
|
<v-checkbox class="my-0" v-model="filterUnread" :label="$t('modals.rss.filterRead')" hide-details />
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<v-btn style="float: right" small elevation="3" @click="markAllAsRead">
|
||||||
|
{{ $t('modals.rss.markAllAsRead') }}
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #[`item.title`]="{ item }">
|
<template #[`item.title`]="{ item }">
|
||||||
|
@ -103,7 +112,10 @@ export default defineComponent({
|
||||||
;(this.rss as RssState).feeds.forEach((feed: Feed) => {
|
;(this.rss as RssState).feeds.forEach((feed: Feed) => {
|
||||||
feed.articles && articles.push(...feed.articles.map(article => ({ feedName: feed.name, parsedDate: new Date(article.date), ...article })))
|
feed.articles && articles.push(...feed.articles.map(article => ({ feedName: feed.name, parsedDate: new Date(article.date), ...article })))
|
||||||
})
|
})
|
||||||
return articles.filter(article => (this.filterUnread ? !article.isRead : true))
|
return articles
|
||||||
|
},
|
||||||
|
unreadArticles() {
|
||||||
|
return this.articles.filter(article => !article.isRead)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -124,6 +136,11 @@ export default defineComponent({
|
||||||
await qbit.markAsRead(item.feedName, item.id)
|
await qbit.markAsRead(item.feedName, item.id)
|
||||||
this.$store.commit('FETCH_FEEDS')
|
this.$store.commit('FETCH_FEEDS')
|
||||||
},
|
},
|
||||||
|
async markAllAsRead() {
|
||||||
|
for (const article of this.unreadArticles) {
|
||||||
|
await this.markAsRead(article)
|
||||||
|
}
|
||||||
|
},
|
||||||
handleKeyboardShortcut(e: KeyboardEvent) {
|
handleKeyboardShortcut(e: KeyboardEvent) {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
this.close()
|
this.close()
|
||||||
|
|
Loading…
Reference in a new issue