Update itemTagsSelected migration

This commit is contained in:
advplyr 2023-04-27 17:18:54 -05:00
parent 0387436111
commit 56e213d654

View File

@ -169,11 +169,10 @@ class User {
if (this.permissions.accessAllTags === undefined) this.permissions.accessAllTags = true if (this.permissions.accessAllTags === undefined) this.permissions.accessAllTags = true
// Explicit content restriction permission added v2.0.18 // Explicit content restriction permission added v2.0.18
if (this.permissions.accessExplicitContent === undefined) this.permissions.accessExplicitContent = true if (this.permissions.accessExplicitContent === undefined) this.permissions.accessExplicitContent = true
// itemTagsAccessible was renamed to itemTagsSelected in version v2.x // itemTagsAccessible was renamed to itemTagsSelected in version v2.2.20
if (this.itemTagsAccessible) { if (user.itemTagsAccessible?.length) {
this.permissions.selectedTagsNotAccessible = false this.permissions.selectedTagsNotAccessible = false
this.itemTagsSelected = this.itemTagsAccessible user.itemTagsSelected = user.itemTagsAccessible
this.itemTagsAccessible = undefined
} }
this.librariesAccessible = [...(user.librariesAccessible || [])] this.librariesAccessible = [...(user.librariesAccessible || [])]
@ -352,10 +351,10 @@ class User {
checkCanAccessLibraryItemWithTags(tags) { checkCanAccessLibraryItemWithTags(tags) {
if (this.permissions.accessAllTags) return true if (this.permissions.accessAllTags) return true
if (this.permissions.selectedTagsNotAccessible) { if (this.permissions.selectedTagsNotAccessible) {
if (!tags || !tags.length) return true if (!tags?.length) return true
return tags.every(tag => !this.itemTagsSelected.includes(tag)) return tags.every(tag => !this.itemTagsSelected.includes(tag))
} }
if (!tags || !tags.length) return false if (!tags?.length) return false
return this.itemTagsSelected.some(tag => tags.includes(tag)) return this.itemTagsSelected.some(tag => tags.includes(tag))
} }