perf(webui): reduce number of API calls on app initial load

This commit is contained in:
Gauthier Roebroeck 2022-02-14 10:20:17 +08:00
parent 5f8894d47a
commit f7dc98aa7e
2 changed files with 22 additions and 11 deletions

View File

@ -473,8 +473,12 @@ export default Vue.extend({
this.modal = val
},
modal(val) {
!val && this.dialogCancel()
val && this.getThumbnails(this.books)
if (val) {
this.getThumbnails(this.books)
this.loadAvailableTags()
} else {
this.dialogCancel()
}
},
books: {
immediate: true,
@ -515,9 +519,6 @@ export default Vue.extend({
links: {},
},
},
async created() {
this.tagsAvailable = await this.$komgaReferential.getTags()
},
computed: {
authorRoles(): NameValue[] {
let remoteRoles = [] as string[]
@ -564,6 +565,9 @@ export default Vue.extend({
},
},
methods: {
async loadAvailableTags() {
this.tagsAvailable = await this.$komgaReferential.getTags()
},
linksLabelRules(label: string): boolean | string {
if (!!this.$_.trim(label)) return true
return this.$t('common.required').toString()

View File

@ -433,8 +433,13 @@ export default Vue.extend({
this.modal = val
},
modal(val) {
!val && this.dialogCancel()
val && this.getThumbnails(this.series)
if(val) {
this.getThumbnails(this.series)
this.loadAvailableTags()
this.loadAvailableGenres()
} else {
this.dialogCancel()
}
},
series(val) {
this.dialogReset(val)
@ -470,10 +475,6 @@ export default Vue.extend({
totalBookCount: {minValue: minValue(1)},
},
},
async created() {
this.genresAvailable = await this.$komgaReferential.getGenres()
this.tagsAvailable = await this.$komgaReferential.getTags()
},
computed: {
single(): boolean {
return !Array.isArray(this.series)
@ -516,6 +517,12 @@ export default Vue.extend({
},
},
methods: {
async loadAvailableTags() {
this.tagsAvailable = await this.$komgaReferential.getTags()
},
async loadAvailableGenres() {
this.genresAvailable = await this.$komgaReferential.getGenres()
},
requiredErrors(fieldName: string): string[] {
const errors = [] as string[]
const formField = this.$v.form!![fieldName] as any