Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve video playlist search UX #4929

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/renderer/components/playlist-info/playlist-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ export default defineComponent({

this.updateQueryDebounce = debounce(this.updateQuery, 500)
},
mounted: function () {
document.addEventListener('keydown', this.keyboardShortcutHandler)
},
beforeDestroy: function () {
document.removeEventListener('keydown', this.keyboardShortcutHandler)
},
methods: {
toggleCopyVideosPrompt: function (force = false) {
if (this.moreVideoDataAvailable && !this.isUserPlaylist && !force) {
Expand Down Expand Up @@ -403,24 +409,18 @@ export default defineComponent({
this.query = query
this.$emit('search-video-query-change', query)
},
enableVideoSearchMode() {
this.searchVideoMode = true
this.$emit('search-video-mode-on')

nextTick(() => {
// Some elements only present after rendering update
this.$refs.searchInput.focus()
})
},
disableVideoSearchMode() {
this.searchVideoMode = false
this.updateQuery('')
this.$emit('search-video-mode-off')

nextTick(() => {
// Some elements only present after rendering update
this.$refs.enableSearchModeButton?.focus()
})
keyboardShortcutHandler(event) {
switch (event.key) {
case 'F':
case 'f':
if (this.searchVideoModeAllowed && ((process.platform !== 'darwin' && event.ctrlKey) || (process.platform === 'darwin' && event.metaKey))) {
nextTick(() => {
// Some elements only present after rendering update
this.$refs.searchInput.focus()
})
}
}
},

...mapActions([
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/components/playlist-info/playlist-info.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@

.searchInputsRow {
margin-block-start: 8px;

display: grid;

/* 2 columns */
grid-template-columns: 1fr auto;
column-gap: 8px;
}

@media only screen and (max-width: 1250px) {
Expand Down
17 changes: 1 addition & 16 deletions src/renderer/components/playlist-info/playlist-info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<hr>

<div
v-if="!searchVideoMode"
class="channelShareWrapper"
>
<router-link
Expand Down Expand Up @@ -107,14 +106,6 @@
</div>

<div class="playlistOptions">
<ft-icon-button
v-if="searchVideoModeAllowed && videoCount > 0 && !editMode"
ref="enableSearchModeButton"
:title="$t('User Playlists.SinglePlaylistView.Search for Videos')"
:icon="['fas', 'search']"
theme="secondary"
@click="enableVideoSearchMode"
/>
<ft-icon-button
v-if="editMode"
:title="$t('User Playlists.Save Changes')"
Expand Down Expand Up @@ -198,7 +189,7 @@
</div>

<div
v-if="searchVideoModeAllowed && searchVideoMode"
v-if="searchVideoModeAllowed"
class="searchInputsRow"
>
<ft-input
Expand All @@ -211,12 +202,6 @@
@input="(input) => updateQueryDebounce(input)"
@clear="updateQueryDebounce('')"
/>
<ft-icon-button
:title="$t('User Playlists.Cancel')"
:icon="['fas', 'times']"
theme="secondary"
@click="disableVideoSearchMode"
/>
</div>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default defineComponent({
this.dataLimit = this.initialDataLimit
}
},
mounted: async function () {
mounted: function () {
document.addEventListener('keydown', this.keyboardShortcutHandler)
},
beforeDestroy: function () {
Expand Down
9 changes: 3 additions & 6 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default defineComponent({
getPlaylistInfoDebounce: function() {},
playlistInEditMode: false,

playlistInVideoSearchMode: false,
videoSearchQuery: '',

promptOpen: false,
Expand Down Expand Up @@ -112,9 +111,8 @@ export default defineComponent({
return this.continuationData !== null
}
},

searchVideoModeAllowed() {
return this.isUserPlaylistRequested
playlistInVideoSearchMode() {
return this.processedVideoSearchQuery !== ''
},
searchQueryTextRequested() {
return this.$route.query.searchQueryText
Expand Down Expand Up @@ -199,8 +197,7 @@ export default defineComponent({
created: function () {
this.getPlaylistInfoDebounce = debounce(this.getPlaylistInfo, 100)

if (this.searchVideoModeAllowed && this.searchQueryTextPresent) {
this.playlistInVideoSearchMode = true
if (this.isUserPlaylistRequested && this.searchQueryTextPresent) {
this.videoSearchQuery = this.searchQueryTextRequested
}
},
Expand Down
4 changes: 1 addition & 3 deletions src/renderer/views/Playlist/Playlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
:view-count="viewCount"
:info-source="infoSource"
:more-video-data-available="moreVideoDataAvailable"
:search-video-mode-allowed="searchVideoModeAllowed"
:search-video-mode-allowed="isUserPlaylistRequested && videoCount > 1"
:search-video-mode-enabled="playlistInVideoSearchMode"
:search-query-text="searchQueryTextRequested"
class="playlistInfo"
Expand All @@ -31,8 +31,6 @@
}"
@enter-edit-mode="playlistInEditMode = true"
@exit-edit-mode="playlistInEditMode = false"
@search-video-mode-on="playlistInVideoSearchMode = true"
@search-video-mode-off="playlistInVideoSearchMode = false"
@search-video-query-change="(v) => videoSearchQuery = v"
@prompt-open="promptOpen = true"
@prompt-close="promptOpen = false"
Expand Down
4 changes: 2 additions & 2 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ User Playlists:
Your saved videos are empty. Click on the save button on the corner of a video to have it listed here: Your saved videos are empty. Click on the save button on the corner of a video to have
it listed here
You have no playlists. Click on the create new playlist button to create a new one.: You have no playlists. Click on the create new playlist button to create a new one.
Empty Search Message: There are no videos in this playlist that matches your search
Empty Search Message: There are no videos in this playlist that match your search
Search bar placeholder: Search for Playlists
Playlists with Matching Videos: Playlists with Matching Videos

Expand Down Expand Up @@ -235,7 +235,7 @@ History:
History: History
Watch History: Watch History
Your history list is currently empty.: Your history list is currently empty.
Empty Search Message: There are no videos in your history that matches your search
Empty Search Message: There are no videos in your history that match your search
Search bar placeholder: "Search in History"
Settings:
# On Settings Page
Expand Down
Loading