mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-03-01 05:29:41 +00:00
Use library default provider in Match/Cover dialogs
This commit is contained in:
parent
ff884f1135
commit
8d687cbce9
3 changed files with 34 additions and 35 deletions
28
artifacts/2026-02-26/match_dialog_default_provider.md
Normal file
28
artifacts/2026-02-26/match_dialog_default_provider.md
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Match Dialog Default Provider
|
||||||
|
|
||||||
|
This specification artifact details the changes made to the "Match" and "Edit" dialogs within the audiobookshelf application to ensure the default metadata provider corresponds to the library's default setting, rather than a globally persisted user selection.
|
||||||
|
|
||||||
|
## Background
|
||||||
|
|
||||||
|
Previously, when matching a book in the "Match" tab of the Edit modal, changing the metadata provider (e.g., from "Audible" to "Google Books") would save that choice to `localStorage` under the key `book-provider`. Subsequent visits to the Match tab for any other book would initialize the provider dropdown with this last-used value.
|
||||||
|
|
||||||
|
This behavior led to a suboptimal user experience, specifically for users who manage multiple libraries with different default metadata providers or specifically want their library's default provider to take precedence by default.
|
||||||
|
|
||||||
|
## Implementation Details
|
||||||
|
|
||||||
|
### Removal of `localStorage` Persistence
|
||||||
|
|
||||||
|
The `Match.vue` component has been updated to remove the persistence of `book-provider` to `localStorage`.
|
||||||
|
|
||||||
|
- The `persistProvider()` method has been removed.
|
||||||
|
- The `submitSearch()` method no longer triggers persistence.
|
||||||
|
|
||||||
|
### Initialization from Library Settings
|
||||||
|
|
||||||
|
The initial provider selection logic in `getDefaultBookProvider()` inside `Match.vue` (and similarly `Cover.vue`) has been refactored:
|
||||||
|
|
||||||
|
- It now queries the Vuex store (`this.$store.getters['libraries/getLibraryProvider']`) utilizing the `libraryId` of the current item.
|
||||||
|
- If the current library has a customized provider, it correctly defaults to that provider.
|
||||||
|
- It falls back to `"google"` safely if no library setting is found or the retrieved provider is invalid.
|
||||||
|
|
||||||
|
This ensures that closing and reopening the Match dialog for another item accurately respects the library's established metadata source configuration.
|
||||||
|
|
@ -244,17 +244,8 @@ export default {
|
||||||
this.searchAuthor = this.mediaMetadata.authorName || ''
|
this.searchAuthor = this.mediaMetadata.authorName || ''
|
||||||
if (this.isPodcast) this.provider = 'itunes'
|
if (this.isPodcast) this.provider = 'itunes'
|
||||||
else {
|
else {
|
||||||
// Migrate from 'all' to 'best' (only once)
|
const libraryProvider = this.$store.getters['libraries/getLibraryProvider'](this.libraryItem.libraryId) || 'google'
|
||||||
const migrationKey = 'book-cover-provider-migrated'
|
this.provider = libraryProvider === 'all' ? 'best' : libraryProvider
|
||||||
const currentProvider = localStorage.getItem('book-cover-provider') || localStorage.getItem('book-provider') || 'google'
|
|
||||||
|
|
||||||
if (!localStorage.getItem(migrationKey) && currentProvider === 'all') {
|
|
||||||
localStorage.setItem('book-cover-provider', 'best')
|
|
||||||
localStorage.setItem(migrationKey, 'true')
|
|
||||||
this.provider = 'best'
|
|
||||||
} else {
|
|
||||||
this.provider = currentProvider
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeCover() {
|
removeCover() {
|
||||||
|
|
@ -304,13 +295,7 @@ export default {
|
||||||
if (this.isPodcast) searchQuery += '&podcast=1'
|
if (this.isPodcast) searchQuery += '&podcast=1'
|
||||||
return searchQuery
|
return searchQuery
|
||||||
},
|
},
|
||||||
persistProvider() {
|
|
||||||
try {
|
|
||||||
localStorage.setItem('book-cover-provider', this.provider)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('PersistProvider', error)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
generateRequestId() {
|
generateRequestId() {
|
||||||
return `cover-search-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
|
return `cover-search-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
|
||||||
},
|
},
|
||||||
|
|
@ -398,9 +383,6 @@ export default {
|
||||||
this.cancelCurrentSearch()
|
this.cancelCurrentSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store provider in local storage
|
|
||||||
this.persistProvider()
|
|
||||||
|
|
||||||
// Setup socket listeners if not already done
|
// Setup socket listeners if not already done
|
||||||
this.addSocketListeners()
|
this.addSocketListeners()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -381,20 +381,12 @@ export default {
|
||||||
checkboxToggled() {
|
checkboxToggled() {
|
||||||
this.selectAll = Object.values(this.selectedMatchUsage).findIndex((v) => v == false) < 0
|
this.selectAll = Object.values(this.selectedMatchUsage).findIndex((v) => v == false) < 0
|
||||||
},
|
},
|
||||||
persistProvider() {
|
|
||||||
try {
|
|
||||||
localStorage.setItem('book-provider', this.provider)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('PersistProvider', error)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getDefaultBookProvider() {
|
getDefaultBookProvider() {
|
||||||
let provider = localStorage.getItem('book-provider')
|
const provider = this.$store.getters['libraries/getLibraryProvider'](this.libraryItem.libraryId) || 'google'
|
||||||
if (!provider) return 'google'
|
|
||||||
// Validate book provider
|
// Validate book provider
|
||||||
if (!this.$store.getters['scanners/checkBookProviderExists'](provider)) {
|
if (!this.$store.getters['scanners/checkBookProviderExists'](provider)) {
|
||||||
console.error('Stored book provider does not exist', provider)
|
console.error('Library default book provider does not exist', provider)
|
||||||
localStorage.removeItem('book-provider')
|
|
||||||
return 'google'
|
return 'google'
|
||||||
}
|
}
|
||||||
return provider
|
return provider
|
||||||
|
|
@ -411,9 +403,6 @@ export default {
|
||||||
this.$toast.warning(this.$strings.ToastTitleRequired)
|
this.$toast.warning(this.$strings.ToastTitleRequired)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.isPodcast) {
|
|
||||||
this.persistProvider()
|
|
||||||
}
|
|
||||||
this.runSearch()
|
this.runSearch()
|
||||||
},
|
},
|
||||||
async runSearch() {
|
async runSearch() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue