Skip to content

Commit 2b282e1

Browse files
committed
* Make additional text work for multi video adding
1 parent 6092275 commit 2b282e1

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

src/renderer/components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
:index="index"
7070
:selected="selectedPlaylistIdList.includes(playlist._id)"
7171
:disabled="playlistDisabled(playlist._id)"
72+
:adding-duplicate-videos-enabled="addingDuplicateVideosEnabled"
7273
@selected="countSelected(playlist._id)"
7374
/>
7475
</div>

src/renderer/components/ft-playlist-selector/ft-playlist-selector.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export default defineComponent({
2828
type: Boolean,
2929
required: true,
3030
},
31+
addingDuplicateVideosEnabled: {
32+
type: Boolean,
33+
required: true,
34+
},
3135
},
3236
emits: ['selected'],
3337
data: function () {
@@ -80,10 +84,40 @@ export default defineComponent({
8084
count: this.loneVideoPresenceCountInPlaylist,
8185
})
8286
},
87+
multiVideoPresenceCountInPlaylist() {
88+
if (this.toBeAddedToPlaylistVideoList.length < 2) { return null }
89+
90+
// Count of to be added videos already present in this playlist
91+
const v = this.toBeAddedToPlaylistVideoList.reduce((accumulator, toBeAddedToVideo) => {
92+
return this.playlist.videos.some((pv) => pv.videoId === toBeAddedToVideo.videoId)
93+
? accumulator + 1
94+
: accumulator
95+
}, 0)
96+
// Don't display zero value
97+
return v === 0 ? null : v
98+
},
99+
multiVideoPresenceCountInPlaylistText() {
100+
if (this.multiVideoPresenceCountInPlaylist == null) { return null }
101+
102+
if (this.addingDuplicateVideosEnabled || this.toBeAddedToPlaylistVideoList.length === this.multiVideoPresenceCountInPlaylist) {
103+
return this.$t('User Playlists.AddVideoPrompt.{videoCount}/{totalVideoCount} Videos Already Added', {
104+
videoCount: this.multiVideoPresenceCountInPlaylist,
105+
totalVideoCount: this.toBeAddedToPlaylistVideoList.length,
106+
})
107+
}
108+
109+
return this.$t('User Playlists.AddVideoPrompt.{videoCount}/{totalVideoCount} Videos Will Be Added', {
110+
videoCount: this.toBeAddedToPlaylistVideoList.length - this.multiVideoPresenceCountInPlaylist,
111+
totalVideoCount: this.toBeAddedToPlaylistVideoList.length,
112+
})
113+
},
114+
videoPresenceCountInPlaylistText() {
115+
return this.loneVideoPresenceCountInPlaylistText ?? this.multiVideoPresenceCountInPlaylistText
116+
},
83117
videoPresenceCountInPlaylistTextVisible() {
84118
if (!this.videoPresenceCountInPlaylistTextShouldBeVisible) { return false }
85119

86-
return this.loneVideoPresenceCountInPlaylistText != null
120+
return this.videoPresenceCountInPlaylistText != null
87121
},
88122
},
89123
created: function () {

src/renderer/components/ft-playlist-selector/ft-playlist-selector.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
v-if="videoPresenceCountInPlaylistTextVisible"
4646
class="videoPresenceCount"
4747
>
48-
{{ loneVideoPresenceCountInPlaylistText }}
48+
{{ videoPresenceCountInPlaylistText }}
4949
</div>
5050
</div>
5151
</div>

static/locales/en-US.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ User Playlists:
218218
Save: Save
219219

220220
Added {count} Times: 'Already Added | Added {count} Times'
221+
"{videoCount}/{totalVideoCount} Videos Will Be Added": '{videoCount}/{totalVideoCount} Videos Will Be Added'
222+
"{videoCount}/{totalVideoCount} Videos Already Added": '{videoCount}/{totalVideoCount} Videos Already Added'
221223

222224
Toast:
223225
You haven't selected any playlist yet.: You haven't selected any playlist yet.

0 commit comments

Comments
 (0)