Skip to content

Commit

Permalink
perf(webui): reduce number of API calls on app initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Feb 14, 2022
1 parent 5f8894d commit f7dc98a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
14 changes: 9 additions & 5 deletions komga-webui/src/components/dialogs/EditBooksDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -515,9 +519,6 @@ export default Vue.extend({
links: {},
},
},
async created() {
this.tagsAvailable = await this.$komgaReferential.getTags()
},
computed: {
authorRoles(): NameValue[] {
let remoteRoles = [] as string[]
Expand Down Expand Up @@ -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()
Expand Down
19 changes: 13 additions & 6 deletions komga-webui/src/components/dialogs/EditSeriesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f7dc98a

Please sign in to comment.