diff --git a/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue b/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue index 45b67fb29f21a..dc3bae0501832 100644 --- a/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue +++ b/src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue @@ -69,6 +69,7 @@ :index="index" :selected="selectedPlaylistIdList.includes(playlist._id)" :disabled="playlistDisabled(playlist._id)" + :adding-duplicate-videos-enabled="addingDuplicateVideosEnabled" @selected="countSelected(playlist._id)" /> diff --git a/src/renderer/components/ft-playlist-selector/ft-playlist-selector.js b/src/renderer/components/ft-playlist-selector/ft-playlist-selector.js index ade16b59ebd77..d6bd317b4191f 100644 --- a/src/renderer/components/ft-playlist-selector/ft-playlist-selector.js +++ b/src/renderer/components/ft-playlist-selector/ft-playlist-selector.js @@ -28,6 +28,10 @@ export default defineComponent({ type: Boolean, required: true, }, + addingDuplicateVideosEnabled: { + type: Boolean, + required: true, + }, }, emits: ['selected'], data: function () { @@ -80,10 +84,40 @@ export default defineComponent({ count: this.loneVideoPresenceCountInPlaylist, }) }, + multiVideoPresenceCountInPlaylist() { + if (this.toBeAddedToPlaylistVideoList.length < 2) { return null } + + // Count of to be added videos already present in this playlist + const v = this.toBeAddedToPlaylistVideoList.reduce((accumulator, toBeAddedToVideo) => { + return this.playlist.videos.some((pv) => pv.videoId === toBeAddedToVideo.videoId) + ? accumulator + 1 + : accumulator + }, 0) + // Don't display zero value + return v === 0 ? null : v + }, + multiVideoPresenceCountInPlaylistText() { + if (this.multiVideoPresenceCountInPlaylist == null) { return null } + + if (this.addingDuplicateVideosEnabled || this.toBeAddedToPlaylistVideoList.length === this.multiVideoPresenceCountInPlaylist) { + return this.$t('User Playlists.AddVideoPrompt.{videoCount}/{totalVideoCount} Videos Already Added', { + videoCount: this.multiVideoPresenceCountInPlaylist, + totalVideoCount: this.toBeAddedToPlaylistVideoList.length, + }) + } + + return this.$t('User Playlists.AddVideoPrompt.{videoCount}/{totalVideoCount} Videos Will Be Added', { + videoCount: this.toBeAddedToPlaylistVideoList.length - this.multiVideoPresenceCountInPlaylist, + totalVideoCount: this.toBeAddedToPlaylistVideoList.length, + }) + }, + videoPresenceCountInPlaylistText() { + return this.loneVideoPresenceCountInPlaylistText ?? this.multiVideoPresenceCountInPlaylistText + }, videoPresenceCountInPlaylistTextVisible() { if (!this.videoPresenceCountInPlaylistTextShouldBeVisible) { return false } - return this.loneVideoPresenceCountInPlaylistText != null + return this.videoPresenceCountInPlaylistText != null }, }, created: function () { diff --git a/src/renderer/components/ft-playlist-selector/ft-playlist-selector.vue b/src/renderer/components/ft-playlist-selector/ft-playlist-selector.vue index 060043169c60f..4f5bc69a6521d 100644 --- a/src/renderer/components/ft-playlist-selector/ft-playlist-selector.vue +++ b/src/renderer/components/ft-playlist-selector/ft-playlist-selector.vue @@ -45,7 +45,7 @@ v-if="videoPresenceCountInPlaylistTextVisible" class="videoPresenceCount" > - {{ loneVideoPresenceCountInPlaylistText }} + {{ videoPresenceCountInPlaylistText }} diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index fec75c978977a..170f2c2a780f0 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -218,6 +218,8 @@ User Playlists: Save: Save Added {count} Times: 'Already Added | Added {count} Times' + "{videoCount}/{totalVideoCount} Videos Will Be Added": '{videoCount}/{totalVideoCount} Videos Will Be Added' + "{videoCount}/{totalVideoCount} Videos Already Added": '{videoCount}/{totalVideoCount} Videos Already Added' Toast: You haven't selected any playlist yet.: You haven't selected any playlist yet.