mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-23 12:19:38 +00:00
Merge
This commit is contained in:
commit
8b685436de
55 changed files with 641 additions and 236 deletions
|
|
@ -322,6 +322,7 @@ class Book {
|
|||
tags: this.tags.filter(t => cleanStringForSearch(t).includes(query)),
|
||||
series: this.metadata.searchSeries(query),
|
||||
authors: this.metadata.searchAuthors(query),
|
||||
narrators: this.metadata.searchNarrators(query),
|
||||
matchKey: null,
|
||||
matchText: null
|
||||
}
|
||||
|
|
@ -336,10 +337,12 @@ class Book {
|
|||
} else if (payload.series.length) {
|
||||
payload.matchKey = 'series'
|
||||
payload.matchText = this.metadata.seriesName
|
||||
}
|
||||
else if (payload.tags.length) {
|
||||
} else if (payload.tags.length) {
|
||||
payload.matchKey = 'tags'
|
||||
payload.matchText = this.tags.join(', ')
|
||||
} else if (payload.narrators.length) {
|
||||
payload.matchKey = 'narrators'
|
||||
payload.matchText = this.metadata.narratorName
|
||||
}
|
||||
}
|
||||
return payload
|
||||
|
|
|
|||
|
|
@ -381,6 +381,9 @@ class BookMetadata {
|
|||
searchAuthors(query) {
|
||||
return this.authors.filter(au => cleanStringForSearch(au.name).includes(query))
|
||||
}
|
||||
searchNarrators(query) {
|
||||
return this.narrators.filter(n => cleanStringForSearch(n).includes(query))
|
||||
}
|
||||
searchQuery(query) { // Returns key if match is found
|
||||
const keysToCheck = ['title', 'asin', 'isbn']
|
||||
for (const key of keysToCheck) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class User {
|
|||
|
||||
this.permissions = {}
|
||||
this.librariesAccessible = [] // Library IDs (Empty if ALL libraries)
|
||||
this.itemTagsAccessible = [] // Empty if ALL item tags accessible
|
||||
this.itemTagsSelected = [] // Empty if ALL item tags accessible
|
||||
|
||||
if (user) {
|
||||
this.construct(user)
|
||||
|
|
@ -86,7 +86,7 @@ class User {
|
|||
createdAt: this.createdAt,
|
||||
permissions: this.permissions,
|
||||
librariesAccessible: [...this.librariesAccessible],
|
||||
itemTagsAccessible: [...this.itemTagsAccessible]
|
||||
itemTagsSelected: [...this.itemTagsSelected]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ class User {
|
|||
createdAt: this.createdAt,
|
||||
permissions: this.permissions,
|
||||
librariesAccessible: [...this.librariesAccessible],
|
||||
itemTagsAccessible: [...this.itemTagsAccessible]
|
||||
itemTagsSelected: [...this.itemTagsSelected]
|
||||
}
|
||||
if (minimal) {
|
||||
delete json.mediaProgress
|
||||
|
|
@ -169,9 +169,14 @@ class User {
|
|||
if (this.permissions.accessAllTags === undefined) this.permissions.accessAllTags = true
|
||||
// Explicit content restriction permission added v2.0.18
|
||||
if (this.permissions.accessExplicitContent === undefined) this.permissions.accessExplicitContent = true
|
||||
// itemTagsAccessible was renamed to itemTagsSelected in version v2.2.20
|
||||
if (user.itemTagsAccessible?.length) {
|
||||
this.permissions.selectedTagsNotAccessible = false
|
||||
user.itemTagsSelected = user.itemTagsAccessible
|
||||
}
|
||||
|
||||
this.librariesAccessible = [...(user.librariesAccessible || [])]
|
||||
this.itemTagsAccessible = [...(user.itemTagsAccessible || [])]
|
||||
this.itemTagsSelected = [...(user.itemTagsSelected || [])]
|
||||
}
|
||||
|
||||
update(payload) {
|
||||
|
|
@ -228,19 +233,21 @@ class User {
|
|||
// Update accessible tags
|
||||
if (this.permissions.accessAllTags) {
|
||||
// Access all tags
|
||||
if (this.itemTagsAccessible.length) {
|
||||
this.itemTagsAccessible = []
|
||||
if (this.itemTagsSelected.length) {
|
||||
this.itemTagsSelected = []
|
||||
this.permissions.selectedTagsNotAccessible = false
|
||||
hasUpdates = true
|
||||
}
|
||||
} else if (payload.itemTagsAccessible !== undefined) {
|
||||
if (payload.itemTagsAccessible.length) {
|
||||
if (payload.itemTagsAccessible.join(',') !== this.itemTagsAccessible.join(',')) {
|
||||
} else if (payload.itemTagsSelected !== undefined) {
|
||||
if (payload.itemTagsSelected.length) {
|
||||
if (payload.itemTagsSelected.join(',') !== this.itemTagsSelected.join(',')) {
|
||||
hasUpdates = true
|
||||
this.itemTagsAccessible = [...payload.itemTagsAccessible]
|
||||
this.itemTagsSelected = [...payload.itemTagsSelected]
|
||||
}
|
||||
} else if (this.itemTagsAccessible.length > 0) {
|
||||
} else if (this.itemTagsSelected.length > 0) {
|
||||
hasUpdates = true
|
||||
this.itemTagsAccessible = []
|
||||
this.itemTagsSelected = []
|
||||
this.permissions.selectedTagsNotAccessible = false
|
||||
}
|
||||
}
|
||||
return hasUpdates
|
||||
|
|
@ -343,8 +350,12 @@ class User {
|
|||
|
||||
checkCanAccessLibraryItemWithTags(tags) {
|
||||
if (this.permissions.accessAllTags) return true
|
||||
if (!tags || !tags.length) return false
|
||||
return this.itemTagsAccessible.some(tag => tags.includes(tag))
|
||||
if (this.permissions.selectedTagsNotAccessible) {
|
||||
if (!tags?.length) return true
|
||||
return tags.every(tag => !this.itemTagsSelected.includes(tag))
|
||||
}
|
||||
if (!tags?.length) return false
|
||||
return this.itemTagsSelected.some(tag => tags.includes(tag))
|
||||
}
|
||||
|
||||
checkCanAccessLibraryItem(libraryItem) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue