fix(webui): don't display nothing to show while still loading

closes #648
This commit is contained in:
Gauthier Roebroeck 2021-09-01 12:06:20 +08:00
parent e4b136b28d
commit dce4dde6b8

View file

@ -42,7 +42,7 @@
/> />
<v-container fluid> <v-container fluid>
<empty-state v-if="allEmpty" <empty-state v-if="allEmpty && !loading"
:title="$t('common.nothing_to_show')" :title="$t('common.nothing_to_show')"
icon="mdi-help-circle" icon="mdi-help-circle"
icon-color="secondary" icon-color="secondary"
@ -198,6 +198,7 @@ export default Vue.extend({
}, },
data: () => { data: () => {
return { return {
loading: false,
library: undefined as LibraryDto | undefined, library: undefined as LibraryDto | undefined,
newSeries: [] as SeriesDto[], newSeries: [] as SeriesDto[],
updatedSeries: [] as SeriesDto[], updatedSeries: [] as SeriesDto[],
@ -248,8 +249,8 @@ export default Vue.extend({
this.loadAll(val) this.loadAll(val)
}, },
'$store.state.komgaLibraries.libraries': { '$store.state.komgaLibraries.libraries': {
handler(val){ handler(val) {
if(val.length === 0) this.$router.push({name: 'welcome'}) if (val.length === 0) this.$router.push({name: 'welcome'})
else this.reload() else this.reload()
}, },
}, },
@ -283,32 +284,36 @@ export default Vue.extend({
this.reload() this.reload()
} }
}, },
bookChanged(event: BookSseDto){ bookChanged(event: BookSseDto) {
if (this.libraryId === LIBRARIES_ALL || event.libraryId === this.libraryId) { if (this.libraryId === LIBRARIES_ALL || event.libraryId === this.libraryId) {
this.reload() this.reload()
} }
}, },
readProgressChanged(event: ReadProgressSseDto){ readProgressChanged(event: ReadProgressSseDto) {
if (this.inProgressBooks.some(b => b.id === event.bookId)) this.reload() if (this.inProgressBooks.some(b => b.id === event.bookId)) this.reload()
else if (this.latestBooks.some(b => b.id === event.bookId)) this.reload() else if (this.latestBooks.some(b => b.id === event.bookId)) this.reload()
else if (this.onDeckBooks.some(b => b.id === event.bookId)) this.reload() else if (this.onDeckBooks.some(b => b.id === event.bookId)) this.reload()
else if (this.recentlyReleasedBooks.some(b => b.id === event.bookId)) this.reload() else if (this.recentlyReleasedBooks.some(b => b.id === event.bookId)) this.reload()
else if (this.recentlyReadBooks.some(b => b.id === event.bookId)) this.reload() else if (this.recentlyReadBooks.some(b => b.id === event.bookId)) this.reload()
}, },
reload: throttle(function(this: any) { reload: throttle(function (this: any) {
this.loadAll(this.libraryId) this.loadAll(this.libraryId)
}, 5000), }, 5000),
loadAll(libraryId: string) { loadAll(libraryId: string) {
this.loading = true
this.library = this.getLibraryLazy(libraryId) this.library = this.getLibraryLazy(libraryId)
this.selectedSeries = [] this.selectedSeries = []
this.selectedBooks = [] this.selectedBooks = []
this.loadInProgressBooks(libraryId) Promise.all([this.loadInProgressBooks(libraryId),
this.loadOnDeckBooks(libraryId) this.loadOnDeckBooks(libraryId),
this.loadRecentlyReleasedBooks(libraryId) this.loadRecentlyReleasedBooks(libraryId),
this.loadLatestBooks(libraryId) this.loadLatestBooks(libraryId),
this.loadNewSeries(libraryId) this.loadNewSeries(libraryId),
this.loadUpdatedSeries(libraryId) this.loadUpdatedSeries(libraryId),
this.loadRecentlyReadBooks(libraryId) this.loadRecentlyReadBooks(libraryId),
]).then(x => {
this.loading = false
})
}, },
async loadNewSeries(libraryId: string) { async loadNewSeries(libraryId: string) {
this.newSeries = (await this.$komgaSeries.getNewSeries(this.getRequestLibraryId(libraryId))).content this.newSeries = (await this.$komgaSeries.getNewSeries(this.getRequestLibraryId(libraryId))).content