From 1767f4e842d058edd3e0ca3922c2c1efb9ed981c Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Wed, 10 Apr 2024 06:31:44 -0500 Subject: [PATCH 1/3] 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. --- src/renderer/views/Playlist/Playlist.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/renderer/views/Playlist/Playlist.js b/src/renderer/views/Playlist/Playlist.js index 936f96abebbdb..59674fbd11f17 100644 --- a/src/renderer/views/Playlist/Playlist.js +++ b/src/renderer/views/Playlist/Playlist.js @@ -142,7 +142,11 @@ 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' || typeof (v.author) !== 'string') { + return false + } else { + return v.title.toLowerCase().includes(this.processedVideoSearchQuery) || v.author.toLowerCase().includes(this.processedVideoSearchQuery) + } }) }, visiblePlaylistItems: function () { From 2b5422bd016069d5b7920a0f7bc2ac23237776ce Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Wed, 10 Apr 2024 11:59:12 -0500 Subject: [PATCH 2/3] Update title/author search handling to not fail if only one of the base values is invalid --- src/renderer/views/History/History.js | 10 ++++++---- src/renderer/views/Playlist/Playlist.js | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/renderer/views/History/History.js b/src/renderer/views/History/History.js index ffa871ea23886..0a494d7c51918 100644 --- a/src/renderer/views/History/History.js +++ b/src/renderer/views/History/History.js @@ -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 }) diff --git a/src/renderer/views/Playlist/Playlist.js b/src/renderer/views/Playlist/Playlist.js index 59674fbd11f17..73183f381b408 100644 --- a/src/renderer/views/Playlist/Playlist.js +++ b/src/renderer/views/Playlist/Playlist.js @@ -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 () { From 451925fcbc15fab193255793798d932c8838cd2f Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Wed, 10 Apr 2024 21:04:12 -0500 Subject: [PATCH 3/3] Add author-searching to 'Find playlist with video' results --- .../ft-playlist-add-video-prompt.js | 2 +- src/renderer/views/UserPlaylists/UserPlaylists.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js b/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js index 4f5a944e4764e..ed9c0fbf10f99 100644 --- a/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js +++ b/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.js @@ -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 } } diff --git a/src/renderer/views/UserPlaylists/UserPlaylists.js b/src/renderer/views/UserPlaylists/UserPlaylists.js index e4d7f3f2888e3..1be2a9bdc0e8a 100644 --- a/src/renderer/views/UserPlaylists/UserPlaylists.js +++ b/src/renderer/views/UserPlaylists/UserPlaylists.js @@ -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 } }