Skip to content

Commit

Permalink
! Fix playlist link in watch view
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Dec 20, 2023
1 parent 42424fd commit 6647099
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineComponent({
type: String,
required: true,
},
playlistType: {
type: String,
default: null
},
videoId: {
type: String,
required: true,
Expand All @@ -48,6 +52,8 @@ export default defineComponent({
playlistTitle: '',
playlistItems: [],
randomizedPlaylistItems: [],

getPlaylistInfoRun: false,
}
},
computed: {
Expand All @@ -59,6 +65,9 @@ export default defineComponent({
return this.$store.getters.getBackendFallback
},

isUserPlaylist: function () {
return this.playlistType === 'user'
},
userPlaylistsReady: function () {
return this.$store.getters.getPlaylistsReady
},
Expand All @@ -73,11 +82,6 @@ export default defineComponent({
selectedUserPlaylistLastUpdatedAt () {
return this.selectedUserPlaylist?.lastUpdatedAt
},
playlistType() {
if (this.selectedUserPlaylist != null) { return 'user' }

return ''
},

currentVideoIndexZeroBased: function () {
return this.playlistItems.findIndex((item) => {
Expand Down Expand Up @@ -138,6 +142,16 @@ export default defineComponent({
videoIsNotPlaylistItem: function () {
return this.videoIndexInPlaylistItems === -1
},

playlistPageLinkTo() {
// For `router-link` attribute `to`
return {
path: `/playlist/${this.playlistId}`,
query: {
playlistType: this.isUserPlaylist ? 'user' : '',
},
}
},
},
watch: {
userPlaylistsReady: function() {
Expand Down Expand Up @@ -202,7 +216,7 @@ export default defineComponent({
this.getPlaylistInformationLocal()
}
}
}
},
},
mounted: function () {
const cachedPlaylist = this.$store.getters.getCachedPlaylist
Expand All @@ -225,8 +239,13 @@ export default defineComponent({
},
methods: {
getPlaylistInfoWithDelay: function () {
if (this.getPlaylistInfoRun) { return }

this.isLoading = true
if (!this.userPlaylistsReady) { return }
// `selectedUserPlaylist` result accuracy relies on data being ready
if (this.isUserPlaylist && !this.userPlaylistsReady) { return }

this.getPlaylistInfoRun = true

if (this.selectedUserPlaylist != null) {
this.parseUserPlaylist(this.selectedUserPlaylist)
Expand Down Expand Up @@ -358,6 +377,7 @@ export default defineComponent({

loadCachedPlaylistInformation: async function (cachedPlaylist) {
this.isLoading = true
this.getPlaylistInfoRun = true
this.setCachedPlaylist(null)

this.playlistTitle = cachedPlaylist.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
>
<router-link
class="playlistTitleLink"
:to="`/playlist/${playlistId}`"
:to="playlistPageLinkTo"
>
{{ playlistTitle }}
</router-link>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
ref="watchVideoPlaylist"
:watch-view-loading="isLoading"
:playlist-id="playlistId"
:playlist-type="playlistType"
:video-id="videoId"
:playlist-item-id="playlistItemId"
class="watchVideoSideBar watchVideoPlaylist"
Expand Down

0 comments on commit 6647099

Please sign in to comment.