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 create & edit playlist UX #5226

Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,34 @@ export default defineComponent({
newPlaylistVideoObject: function () {
return this.$store.getters.getNewPlaylistVideoObject
},

playlistWithNameExists() {
// Don't show the message with no name input
const playlistName = this.playlistName
if (this.playlistName === '') { return false }

return this.allPlaylists.some((playlist) => {
return playlist.playlistName === playlistName
})
},
},
mounted: function () {
this.playlistName = this.newPlaylistVideoObject.title
// Faster to input required playlist name
nextTick(() => this.$refs.playlistNameInput.focus())
},
methods: {
handlePlaylistNameInput(input) {
this.playlistName = input.trim()
},

createNewPlaylist: function () {
if (this.playlistName === '') {
showToast(this.$t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]'))
return
}

const nameExists = this.allPlaylists.findIndex((playlist) => {
return playlist.playlistName === this.playlistName
})
if (nameExists !== -1) {
showToast(this.$t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]'))
return
}
// Duplicate playlist check moved to template

const playlistObject = {
playlistName: this.playlistName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@
:value="playlistName"
:maxlength="255"
class="playlistNameInput"
@input="(input) => playlistName = input"
@input="(input) => handlePlaylistNameInput(input)"
PikachuEXE marked this conversation as resolved.
Show resolved Hide resolved
@click="createNewPlaylist"
/>
</ft-flex-box>
<ft-flex-box v-if="playlistWithNameExists">
<p>
{{ $t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]') }}
</p>
</ft-flex-box>
<ft-flex-box>
<ft-button
:label="$t('User Playlists.CreatePlaylistPrompt.Create')"
:disabled="playlistWithNameExists"
@click="createNewPlaylist"
/>
<ft-button
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/playlist-info/playlist-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ export default defineComponent({

this.showAddToPlaylistPromptForManyVideos({
videos: this.videos,
newPlaylistDefaultProperties: { title: this.title },
newPlaylistDefaultProperties: {
title: this.channelName === '' ? this.title : `${this.title} | ${this.channelName}`,
},
})
},

Expand Down