Skip to content

Commit

Permalink
perf(webui): load background data in parallel when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed May 31, 2021
1 parent b41499d commit c0d7be9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
6 changes: 4 additions & 2 deletions komga-webui/src/components/LibraryNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ export default Vue.extend({
},
async loadCounts(libraryId: string) {
const lib = libraryId !== LIBRARIES_ALL ? [libraryId] : undefined
this.collectionsCount = (await this.$komgaCollections.getCollections(lib, {size: 1})).totalElements
this.readListsCount = (await this.$komgaReadLists.getReadLists(lib, {size: 1})).totalElements
this.$komgaCollections.getCollections(lib, {size: 0})
.then(v => this.collectionsCount = v.totalElements)
await this.$komgaReadLists.getReadLists(lib, {size: 0})
.then(v => this.readListsCount = v.totalElements)
},
},
})
Expand Down
44 changes: 24 additions & 20 deletions komga-webui/src/views/BrowseBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -454,39 +454,43 @@ export default Vue.extend({
id: this.$route.query.contextId as string,
}
this.book.context = this.context
this.contextName = (await (this.$komgaReadLists.getOneReadList(this.context.id))).name
this.$komgaReadLists.getOneReadList(this.context.id)
.then(v => this.contextName = v.name)
}
// Get siblings depending on origin
if (this?.context.origin === ContextOrigin.READLIST) {
this.siblings = (await this.$komgaReadLists.getBooks(this.context.id, {unpaged: true} as PageRequest)).content
this.$komgaReadLists.getBooks(this.context.id, {unpaged: true} as PageRequest)
.then(v => this.siblings = v.content)
} else {
this.siblings = (await this.$komgaSeries.getBooks(this.book.seriesId, {unpaged: true} as PageRequest)).content
this.$komgaSeries.getBooks(this.book.seriesId, {unpaged: true} as PageRequest)
.then(v => this.siblings = v.content)
}
this.readLists = await this.$komgaBooks.getReadLists(this.bookId)
this.$komgaBooks.getReadLists(this.bookId)
.then(v => this.readLists = v)
if (this.$_.has(this.book, 'metadata.title')) {
document.title = `Komga - ${getBookTitleCompact(this.book.metadata.title, this.series.metadata.title)}`
}
try {
if (this?.context.origin === ContextOrigin.READLIST) {
this.siblingNext = await this.$komgaReadLists.getBookSiblingNext(this.context.id, bookId)
} else {
this.siblingNext = await this.$komgaBooks.getBookSiblingNext(bookId)
}
} catch (e) {
this.siblingNext = {} as BookDto
if (this?.context.origin === ContextOrigin.READLIST) {
this.$komgaReadLists.getBookSiblingNext(this.context.id, bookId)
.then(v => this.siblingNext = v)
.catch(e => this.siblingNext = {} as BookDto)
} else {
this.$komgaBooks.getBookSiblingNext(bookId)
.then(v => this.siblingNext = v)
.catch(e => this.siblingNext = {} as BookDto)
}
try {
if (this?.context.origin === ContextOrigin.READLIST) {
this.siblingPrevious = await this.$komgaReadLists.getBookSiblingPrevious(this.context.id, bookId)
} else {
this.siblingPrevious = await this.$komgaBooks.getBookSiblingPrevious(bookId)
}
} catch (e) {
this.siblingPrevious = {} as BookDto
if (this?.context.origin === ContextOrigin.READLIST) {
this.$komgaReadLists.getBookSiblingPrevious(this.context.id, bookId)
.then(v => this.siblingPrevious = v)
.catch(e => this.siblingPrevious = {} as BookDto)
} else {
this.$komgaBooks.getBookSiblingPrevious(bookId)
.then(v => this.siblingPrevious = v)
.catch(e => this.siblingPrevious = {} as BookDto)
}
},
analyze() {
Expand Down
3 changes: 2 additions & 1 deletion komga-webui/src/views/BrowseCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ export default Vue.extend({
this.selectedSeries = []
},
async loadCollection(collectionId: string) {
this.collection = await this.$komgaCollections.getOneCollection(collectionId)
this.$komgaCollections.getOneCollection(collectionId)
.then(v => this.collection = v)
await this.loadSeries(collectionId)
},
Expand Down
3 changes: 2 additions & 1 deletion komga-webui/src/views/BrowseReadList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export default Vue.extend({
}
},
async loadReadList (readListId: string) {
this.readList = await this.$komgaReadLists.getOneReadList(readListId)
this.$komgaReadLists.getOneReadList(readListId)
.then(v => this.readList = v)
this.books = (await this.$komgaReadLists.getBooks(readListId, { unpaged: true } as PageRequest)).content
this.books.forEach((x: BookDto) => x.context = { origin: ContextOrigin.READLIST, id: readListId })
this.booksCopy = [...this.books]
Expand Down
6 changes: 4 additions & 2 deletions komga-webui/src/views/BrowseSeries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,10 @@ export default Vue.extend({
if (event.seriesId === this.seriesId) this.loadSeries(this.seriesId)
},
async loadSeries(seriesId: string) {
this.series = await this.$komgaSeries.getOneSeries(seriesId)
this.collections = await this.$komgaSeries.getCollections(seriesId)
this.$komgaSeries.getOneSeries(seriesId)
.then(v => this.series = v)
this.$komgaSeries.getCollections(seriesId)
.then(v => this.collections = v)
await this.loadPage(seriesId, this.page, this.sortActive)
},
Expand Down

0 comments on commit c0d7be9

Please sign in to comment.