Skip to content

Commit

Permalink
fix/refactor: make sure toast only shows when a item is missing a dur…
Browse files Browse the repository at this point in the history
…ation/use a foreach loop to check the videos in a playlist
  • Loading branch information
Hoverth committed Sep 30, 2024
1 parent c903044 commit aebeb44
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/renderer/views/Playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,19 +436,18 @@ export default defineComponent({

getDurationPlaylistItems: function () {
const modifiedPlaylistItems = deepCopy(this.playlistItems)
for (const v in modifiedPlaylistItems) {
const video = modifiedPlaylistItems[v]
modifiedPlaylistItems.forEach(video => {
if (!checkDurationFromVideo(video)) {
const videoHistory = this.$store.getters.getHistoryCacheById[modifiedPlaylistItems[v].videoId]
if (typeof videoHistory !== 'undefined') modifiedPlaylistItems[v].lengthSeconds = videoHistory.lengthSeconds
const videoHistory = this.$store.getters.getHistoryCacheById[video.videoId]
if (typeof videoHistory !== 'undefined') video.lengthSeconds = videoHistory.lengthSeconds
}
}
})
return modifiedPlaylistItems
},

showNoticesSometimes: function (playlistItems) {
if (this.alreadyShownNotice) return
const anyVideoMissingDuration = playlistItems.some(v => checkDurationFromVideo(v))
const anyVideoMissingDuration = playlistItems.some(v => !checkDurationFromVideo(v))
if (anyVideoMissingDuration) {
showToast(this.$t('User Playlists.SinglePlaylistView.Toast.This playlist has a video with a duration error'), 5000)
this.alreadyShownNotice = true
Expand Down

0 comments on commit aebeb44

Please sign in to comment.