mirror of
https://github.com/gotson/komga.git
synced 2025-12-21 07:56:57 +01:00
perf(webui): load background data in parallel when possible
This commit is contained in:
parent
b41499d775
commit
c0d7be9627
5 changed files with 36 additions and 26 deletions
|
|
@ -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)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue