Skip to content

Commit

Permalink
Update title/author search handling to not fail if only one of the ba…
Browse files Browse the repository at this point in the history
…se values is invalid
  • Loading branch information
kommunarr committed Apr 10, 2024
1 parent 1767f4e commit 2b5422b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/renderer/views/History/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ export default defineComponent({
if (this.processedVideoSearchQuery === '') { return this.playlistItems }

return this.playlistItems.filter((v) => {
if (typeof (v.title) !== 'string' || typeof (v.author) !== 'string') {
return false
} else {
return v.title.toLowerCase().includes(this.processedVideoSearchQuery) || v.author.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 () {
Expand Down

0 comments on commit 2b5422b

Please sign in to comment.