Initialise the selected provider to the default for the library when the batch quick match is first opened or if the user has switched libraries.

This commit is contained in:
Nick Thomson 2022-09-24 18:23:33 +01:00
parent 9983fe7d66
commit 11e3cf4f19

View File

@ -54,8 +54,10 @@ export default {
data() { data() {
return { return {
processing: false, processing: false,
isScrollable: false,
lastUsedLibrary: undefined,
options: { options: {
provider: 'google', provider: undefined,
overrideDetails: true, overrideDetails: true,
overrideCover: true, overrideCover: true,
overrideDefaults: true overrideDefaults: true
@ -66,6 +68,13 @@ export default {
} }
} }
}, },
watch: {
show: {
handler(newVal) {
this.init()
}
}
},
computed: { computed: {
show: { show: {
get() { get() {
@ -90,34 +99,45 @@ export default {
providers() { providers() {
if (this.isPodcast) return this.$store.state.scanners.podcastProviders if (this.isPodcast) return this.$store.state.scanners.podcastProviders
return this.$store.state.scanners.providers return this.$store.state.scanners.providers
} },
libraryProvider() {
return this.$store.getters['libraries/getLibraryProvider'](this.currentLibraryId) || 'google'
},
}, },
methods: { methods: {
doBatchQuickMatch() { init() {
if (!this.selectedBookIds.length) return // If we don't have a set provider (first open of dialog) or we've switched library, set
if (this.processing) return // the selected provider to the current library default provider
if (!this.options.provider || (this.options.lastUsedLibrary != this.currentLibraryId)) {
this.processing = true this.options.lastUsedLibrary = this.currentLibraryId
this.$store.commit('setProcessingBatch', true) this.options.provider = this.libraryProvider;
this.$axios
.$post(`/api/items/batch/quickmatch`, {
options: this.options,
libraryItemIds: this.selectedBookIds
})
.then(() => {
this.$toast.success('Batch quick match success!')
this.processing = false
this.$store.commit('setProcessingBatch', false)
this.show = false
})
.catch((error) => {
this.$toast.error('Batch quick match failed')
console.error('Failed to batch quick match', error)
this.processing = false
this.$store.commit('setProcessingBatch', false)
this.show = false
})
} }
},
doBatchQuickMatch() {
if (!this.selectedBookIds.length) return
if (this.processing) return
this.processing = true
this.$store.commit('setProcessingBatch', true)
this.$axios
.$post(`/api/items/batch/quickmatch`, {
options: this.options,
libraryItemIds: this.selectedBookIds
})
.then(() => {
this.$toast.success('Batch quick match success!')
this.processing = false
this.$store.commit('setProcessingBatch', false)
this.show = false
})
.catch((error) => {
this.$toast.error('Batch quick match failed')
console.error('Failed to batch quick match', error)
this.processing = false
this.$store.commit('setProcessingBatch', false)
this.show = false
})
}
}, },
mounted() {} mounted() {}
} }