diff --git a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js index 1a01b59df8987..f1ca1729aed82 100644 --- a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js +++ b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.js @@ -33,6 +33,25 @@ export default defineComponent({ newPlaylistVideoObject: function () { return this.$store.getters.getNewPlaylistVideoObject }, + + playlistNameEmpty() { + return this.playlistName === '' + }, + playlistNameBlank() { + return !this.playlistNameEmpty && this.playlistName.trim() === '' + }, + 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 + }) + }, + playlistPersistenceDisabled() { + return this.playlistNameEmpty || this.playlistNameBlank || this.playlistWithNameExists + }, }, mounted: function () { this.playlistName = this.newPlaylistVideoObject.title @@ -40,19 +59,19 @@ export default defineComponent({ nextTick(() => this.$refs.playlistNameInput.focus()) }, methods: { - createNewPlaylist: function () { - if (this.playlistName === '') { - showToast(this.$t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]')) + handlePlaylistNameInput(input) { + if (input.trim() === '') { + // Need to show message for blank input + this.playlistName = input 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 - } + this.playlistName = input.trim() + }, + + createNewPlaylist: function () { + // Still possible to attempt to create via pressing enter + if (this.playlistPersistenceDisabled) { return } const playlistObject = { playlistName: this.playlistName, diff --git a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue index 6c7a43f9ba0a3..fcee4bb114c9e 100644 --- a/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue +++ b/src/renderer/components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue @@ -15,13 +15,24 @@ :value="playlistName" :maxlength="255" class="playlistNameInput" - @input="(input) => playlistName = input" + @input="handlePlaylistNameInput" @click="createNewPlaylist" /> + +

+ {{ $t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]') }} +

+
+ +

+ {{ $t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]') }} +

+
{ + // Only compare with other playlists + if (selectedUserPlaylist._id === playlist._id) { return false } + + return playlist.playlistName === playlistName + }) + }, + playlistPersistenceDisabled() { + return this.inputPlaylistNameEmpty || this.inputPlaylistNameBlank || this.inputPlaylistWithNameExists + }, }, watch: { showDeletePlaylistPrompt(shown) { @@ -269,6 +296,16 @@ export default defineComponent({ document.removeEventListener('keydown', this.keyboardShortcutHandler) }, methods: { + handlePlaylistNameInput(input) { + if (input.trim() === '') { + // Need to show message for blank input + this.newTitle = input + return + } + + this.newTitle = input.trim() + }, + toggleCopyVideosPrompt: function (force = false) { if (this.moreVideoDataAvailable && !this.isUserPlaylist && !force) { showToast(this.$t('User Playlists.SinglePlaylistView.Toast["Some videos in the playlist are not loaded yet. Click here to copy anyway."]'), 5000, () => { @@ -279,15 +316,15 @@ export default defineComponent({ this.showAddToPlaylistPromptForManyVideos({ videos: this.videos, - newPlaylistDefaultProperties: { title: this.title }, + newPlaylistDefaultProperties: { + title: this.channelName === '' ? this.title : `${this.title} | ${this.channelName}`, + }, }) }, savePlaylistInfo: function () { - if (this.newTitle === '') { - showToast(this.$t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]')) - return - } + // Still possible to attempt to create via pressing enter + if (this.playlistPersistenceDisabled) { return } const playlist = { playlistName: this.newTitle, diff --git a/src/renderer/components/playlist-info/playlist-info.vue b/src/renderer/components/playlist-info/playlist-info.vue index a5e6c3b33c707..93b9a8bfc5b1a 100644 --- a/src/renderer/components/playlist-info/playlist-info.vue +++ b/src/renderer/components/playlist-info/playlist-info.vue @@ -34,35 +34,51 @@
- -

+ + +

+ {{ $t('User Playlists.SinglePlaylistView.Toast["Playlist name cannot be empty. Please input a name."]') }} +

+
+ +

+ {{ $t('User Playlists.CreatePlaylistPrompt.Toast["There is already a playlist with this name. Please pick a different name."]') }} +

+
+ +