Fix: + Wish silently failed on playlist detail pages (no channel context -> 400)
The per-video + Wish derived its channel from data._channel, which only exists on CHANNEL pages — on a playlist detail page it's data._playlist, so the add posted no youtube_id and the endpoint 400'd (button reverted, nothing happened). Now it falls back to the playlist's owner channel (channel_id/title, else the playlist itself) so wishing a video works on playlist pages too.
This commit is contained in:
parent
62b815a3fe
commit
113a5ded38
1 changed files with 7 additions and 0 deletions
|
|
@ -1619,7 +1619,14 @@
|
|||
};
|
||||
if (on) yc.removeWish('video', id).then(function (d) { setOn(!(d && d.success)); }).catch(function () { btn.disabled = false; });
|
||||
else {
|
||||
// Channel pages carry _channel; playlist pages carry _playlist — fall back
|
||||
// to the playlist's owner channel so + Wish works there too (was a 400).
|
||||
var ch = (data && data._channel) || {};
|
||||
if (!ch.youtube_id && data && data._playlist) {
|
||||
var pl = data._playlist;
|
||||
ch = { youtube_id: pl.channel_id || pl.playlist_id, title: pl.channel_title || pl.title || 'Playlist',
|
||||
avatar_url: pl.thumbnail_url };
|
||||
}
|
||||
yc.addVideos({ youtube_id: ch.youtube_id, title: ch.title, avatar_url: ch.avatar_url },
|
||||
[ytVideoMap[id] || { youtube_id: id, title: '' }])
|
||||
.then(function (d) { setOn(!!(d && d.success)); if (d && d.success && typeof showToast === 'function') showToast('Added to wishlist', 'success'); })
|
||||
|
|
|
|||
Loading…
Reference in a new issue