diff --git a/komga-webui/src/components/SearchBox.vue b/komga-webui/src/components/SearchBox.vue index ed1f33586..ec7e6832a 100644 --- a/komga-webui/src/components/SearchBox.vue +++ b/komga-webui/src/components/SearchBox.vue @@ -19,7 +19,8 @@ :min-width="$vuetify.breakpoint.mdAndUp ? $vuetify.breakpoint.width * .4 : $vuetify.breakpoint.width * .8" > - No results + No results + + + diff --git a/komga-webui/src/views/Search.vue b/komga-webui/src/views/Search.vue index 784bc410e..b44fe353b 100644 --- a/komga-webui/src/views/Search.vue +++ b/komga-webui/src/views/Search.vue @@ -23,9 +23,9 @@
Series
@@ -35,9 +35,21 @@
Books
+ + + + + @@ -53,10 +65,9 @@ import EmptyState from '@/components/EmptyState.vue' import HorizontalScroller from '@/components/HorizontalScroller.vue' import ItemCard from '@/components/ItemCard.vue' import ToolbarSticky from '@/components/ToolbarSticky.vue' +import { BOOK_CHANGED, COLLECTION_CHANGED, LIBRARY_DELETED, SERIES_CHANGED } from '@/types/events' import Vue from 'vue' -const cookiePageSize = 'pagesize' - export default Vue.extend({ name: 'Search', components: { @@ -69,10 +80,23 @@ export default Vue.extend({ return { series: [] as SeriesDto[], books: [] as BookDto[], + collections: [] as CollectionDto[], pageSize: 50, loading: false, } }, + created () { + this.$eventHub.$on(LIBRARY_DELETED, this.reloadResults) + this.$eventHub.$on(SERIES_CHANGED, this.reloadResults) + this.$eventHub.$on(BOOK_CHANGED, this.reloadResults) + this.$eventHub.$on(COLLECTION_CHANGED, this.reloadResults) + }, + beforeDestroy () { + this.$eventHub.$off(LIBRARY_DELETED, this.reloadResults) + this.$eventHub.$off(SERIES_CHANGED, this.reloadResults) + this.$eventHub.$off(BOOK_CHANGED, this.reloadResults) + this.$eventHub.$off(COLLECTION_CHANGED, this.reloadResults) + }, watch: { '$route.query.q': { handler: function (val) { @@ -84,21 +108,26 @@ export default Vue.extend({ }, computed: { emptyResults (): boolean { - return !this.loading && this.series.length === 0 && this.books.length === 0 + return !this.loading && this.series.length === 0 && this.books.length === 0 && this.collections.length === 0 }, }, methods: { + reloadResults () { + this.loadResults(this.$route.query.q.toString()) + }, async loadResults (search: string) { if (search) { this.loading = true this.series = (await this.$komgaSeries.getSeries(undefined, { size: this.pageSize }, search)).content this.books = (await this.$komgaBooks.getBooks(undefined, { size: this.pageSize }, search)).content + this.collections = (await this.$komgaCollections.getCollections(undefined, { size: this.pageSize }, undefined, search)).content this.loading = false } else { this.series = [] this.books = [] + this.collections = [] } }, },