Add back author search in video playlist searching (#4919)

* Add back author search in video playlist searching

Reuses previous paradigm (the paradigm currently in place in History.js). This was the pre-existing behavior before the Playlist PR. See 5c8d49bf51/src/renderer/views/UserPlaylists/UserPlaylists.js (L98-L103).

* Update title/author search handling to not fail if only one of the base values is invalid

* Add author-searching to 'Find playlist with video' results
This commit is contained in:
Jason 2024-04-11 13:46:33 +00:00 committed by GitHub
parent 2d51419797
commit d6e5439b67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View File

@ -119,7 +119,7 @@ export default defineComponent({
if (typeof (playlist.playlistName) !== 'string') { return false }
if (this.doSearchPlaylistsWithMatchingVideos) {
if (playlist.videos.some((v) => v.title.toLowerCase().includes(this.processedQuery))) {
if (playlist.videos.some((v) => v.author.toLowerCase().includes(this.processedQuery) || v.title.toLowerCase().includes(this.processedQuery))) {
return true
}
}

View File

@ -93,11 +93,13 @@ export default defineComponent({
} else {
const lowerCaseQuery = this.query.toLowerCase()
const filteredQuery = this.historyCacheSorted.filter((video) => {
if (typeof (video.title) !== 'string' || typeof (video.author) !== 'string') {
return false
} else {
return video.title.toLowerCase().includes(lowerCaseQuery) || video.author.toLowerCase().includes(lowerCaseQuery)
if (typeof (video.title) === 'string' && video.title.toLowerCase().includes(lowerCaseQuery)) {
return true
} else if (typeof (video.author) === 'string' && video.author.toLowerCase().includes(lowerCaseQuery)) {
return true
}
return false
}).sort((a, b) => {
return b.timeWatched - a.timeWatched
})

View File

@ -142,7 +142,13 @@ export default defineComponent({
if (this.processedVideoSearchQuery === '') { return this.playlistItems }
return this.playlistItems.filter((v) => {
return v.title.toLowerCase().includes(this.processedVideoSearchQuery)
if (typeof (v.title) === 'string' && v.title.toLowerCase().includes(this.processedVideoSearchQuery)) {
return true
} else if (typeof (v.author) === 'string' && v.author.toLowerCase().includes(this.processedVideoSearchQuery)) {
return true
}
return false
})
},
visiblePlaylistItems: function () {

View File

@ -223,7 +223,7 @@ export default defineComponent({
if (typeof (playlist.playlistName) !== 'string') { return false }
if (this.doSearchPlaylistsWithMatchingVideos) {
if (playlist.videos.some((v) => v.title.toLowerCase().includes(this.lowerCaseQuery))) {
if (playlist.videos.some((v) => v.author.toLowerCase().includes(this.lowerCaseQuery) || v.title.toLowerCase().includes(this.lowerCaseQuery))) {
return true
}
}