Skip to content

Commit d6e5439

Browse files
authored
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 https://github.com/FreeTubeApp/FreeTube/blob/5c8d49bf51dde8ffd8c8d291dce3e5ff27b0d9fb/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
1 parent 2d51419 commit d6e5439

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default defineComponent({
119119
if (typeof (playlist.playlistName) !== 'string') { return false }
120120

121121
if (this.doSearchPlaylistsWithMatchingVideos) {
122-
if (playlist.videos.some((v) => v.title.toLowerCase().includes(this.processedQuery))) {
122+
if (playlist.videos.some((v) => v.author.toLowerCase().includes(this.processedQuery) || v.title.toLowerCase().includes(this.processedQuery))) {
123123
return true
124124
}
125125
}

src/renderer/views/History/History.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ export default defineComponent({
9393
} else {
9494
const lowerCaseQuery = this.query.toLowerCase()
9595
const filteredQuery = this.historyCacheSorted.filter((video) => {
96-
if (typeof (video.title) !== 'string' || typeof (video.author) !== 'string') {
97-
return false
98-
} else {
99-
return video.title.toLowerCase().includes(lowerCaseQuery) || video.author.toLowerCase().includes(lowerCaseQuery)
96+
if (typeof (video.title) === 'string' && video.title.toLowerCase().includes(lowerCaseQuery)) {
97+
return true
98+
} else if (typeof (video.author) === 'string' && video.author.toLowerCase().includes(lowerCaseQuery)) {
99+
return true
100100
}
101+
102+
return false
101103
}).sort((a, b) => {
102104
return b.timeWatched - a.timeWatched
103105
})

src/renderer/views/Playlist/Playlist.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ export default defineComponent({
142142
if (this.processedVideoSearchQuery === '') { return this.playlistItems }
143143

144144
return this.playlistItems.filter((v) => {
145-
return v.title.toLowerCase().includes(this.processedVideoSearchQuery)
145+
if (typeof (v.title) === 'string' && v.title.toLowerCase().includes(this.processedVideoSearchQuery)) {
146+
return true
147+
} else if (typeof (v.author) === 'string' && v.author.toLowerCase().includes(this.processedVideoSearchQuery)) {
148+
return true
149+
}
150+
151+
return false
146152
})
147153
},
148154
visiblePlaylistItems: function () {

src/renderer/views/UserPlaylists/UserPlaylists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export default defineComponent({
223223
if (typeof (playlist.playlistName) !== 'string') { return false }
224224

225225
if (this.doSearchPlaylistsWithMatchingVideos) {
226-
if (playlist.videos.some((v) => v.title.toLowerCase().includes(this.lowerCaseQuery))) {
226+
if (playlist.videos.some((v) => v.author.toLowerCase().includes(this.lowerCaseQuery) || v.title.toLowerCase().includes(this.lowerCaseQuery))) {
227227
return true
228228
}
229229
}

0 commit comments

Comments
 (0)