Skip to content

Commit

Permalink
feat(webui): refresh dashboard on action menu actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Jun 26, 2020
1 parent 6ece7b1 commit b6bd735
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions komga-webui/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ import EmptyState from '@/components/EmptyState.vue'
import HorizontalScroller from '@/components/HorizontalScroller.vue'
import ItemCard from '@/components/ItemCard.vue'
import { ReadStatus } from '@/types/enum-books'
import { LIBRARY_DELETED } from '@/types/events'
import { BOOK_CHANGED, LIBRARY_DELETED, SERIES_CHANGED } from '@/types/events'
import Vue from 'vue'
export default Vue.extend({
Expand All @@ -110,37 +110,23 @@ export default Vue.extend({
},
created () {
this.$eventHub.$on(LIBRARY_DELETED, this.loadAll)
this.$eventHub.$on(SERIES_CHANGED, this.loadAll)
this.$eventHub.$on(BOOK_CHANGED, this.loadAll)
},
beforeDestroy () {
this.$eventHub.$off(LIBRARY_DELETED, this.loadAll)
this.$eventHub.$off(SERIES_CHANGED, this.loadAll)
this.$eventHub.$off(BOOK_CHANGED, this.loadAll)
},
mounted () {
this.loadAll()
},
watch: {
editSeriesSingle (val: SeriesDto) {
let index = this.newSeries.findIndex(x => x.id === val.id)
if (index !== -1) {
this.newSeries.splice(index, 1, val)
}
index = this.updatedSeries.findIndex(x => x.id === val.id)
if (index !== -1) {
this.updatedSeries.splice(index, 1, val)
}
this.replaceSeries(val)
},
editBookSingle (val: BookDto) {
let index = this.latestBooks.findIndex(x => x.id === val.id)
if (index !== -1) {
this.latestBooks.splice(index, 1, val)
}
index = this.inProgressBooks.findIndex(x => x.id === val.id)
if (index !== -1) {
this.inProgressBooks.splice(index, 1, val)
}
index = this.onDeckBooks.findIndex(x => x.id === val.id)
if (index !== -1) {
this.onDeckBooks.splice(index, 1, val)
}
this.replaceBook(val)
},
},
computed: {
Expand All @@ -160,6 +146,30 @@ export default Vue.extend({
this.loadInProgressBooks()
this.loadOnDeckBooks()
},
replaceSeries (series: SeriesDto) {
let index = this.newSeries.findIndex(x => x.id === series.id)
if (index !== -1) {
this.newSeries.splice(index, 1, series)
}
index = this.updatedSeries.findIndex(x => x.id === series.id)
if (index !== -1) {
this.updatedSeries.splice(index, 1, series)
}
},
replaceBook (book: BookDto) {
let index = this.latestBooks.findIndex(x => x.id === book.id)
if (index !== -1) {
this.latestBooks.splice(index, 1, book)
}
index = this.inProgressBooks.findIndex(x => x.id === book.id)
if (index !== -1) {
this.inProgressBooks.splice(index, 1, book)
}
index = this.onDeckBooks.findIndex(x => x.id === book.id)
if (index !== -1) {
this.onDeckBooks.splice(index, 1, book)
}
},
async loadNewSeries () {
this.newSeries = (await this.$komgaSeries.getNewSeries()).content
},
Expand Down

0 comments on commit b6bd735

Please sign in to comment.