Skip to content

Commit

Permalink
Implement suggested optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kommunarr committed Jun 4, 2024
1 parent 4f37130 commit 257681e
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,19 @@ export default defineComponent({
},
methods: {
findIndexOfCurrentVideoInPlaylist: function (playlist) {
const playlistItemId = this.playlistItemId
const prevVideoBeforeDeletion = this.prevVideoBeforeDeletion
const videoId = this.videoId
return playlist.findIndex((item) => {
if (item.playlistItemId != null && (this.playlistItemId != null || this.prevVideoBeforeDeletion?.playlistItemId != null)) {
return item.playlistItemId === this.playlistItemId || item.playlistItemId === this.prevVideoBeforeDeletion?.playlistItemId
} else if (item.videoId != null) {
return item.videoId === this.videoId || item.videoId === this.prevVideoBeforeDeletion?.videoId
} else {
return item.id === this.videoId || item.id === this.prevVideoBeforeDeletion?.videoId
if (item.playlistItemId && (playlistItemId || prevVideoBeforeDeletion?.playlistItemId)) {
return item.playlistItemId === playlistItemId || item.playlistItemId === prevVideoBeforeDeletion?.playlistItemId
} else if (item.videoId) {
return item.videoId === videoId || item.videoId === prevVideoBeforeDeletion?.videoId
} else if (item.id) {
return item.id === videoId || item.id === prevVideoBeforeDeletion?.videoId
}

return false
})
},

Expand Down

0 comments on commit 257681e

Please sign in to comment.