Playlist search result: standard 'Add to Watchlist' button (not 'Follow')
The pasted-playlist chip used the YouTube 'Follow' toggle; swapped it for the app-standard watchlist button (library-artist-watchlist-btn — same look/wording used across video + music): + Add to Watchlist ↔ ✓ In Watchlist. The search toggle handler updates the icon/text spans + 'watching' class accordingly. No global handler keys off that class, so reusing it is purely cosmetic.
This commit is contained in:
parent
ef3d4cfdb4
commit
e141e3dcbd
2 changed files with 14 additions and 6 deletions
|
|
@ -262,20 +262,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add / remove the resolved playlist chip to the watchlist.
|
// Add / remove the resolved playlist chip to the watchlist (standard watchlist button).
|
||||||
|
function setPlBtn(btn, on) {
|
||||||
|
btn.classList.toggle('watching', on);
|
||||||
|
var ic = btn.querySelector('.watchlist-icon'); if (ic) ic.textContent = on ? '✓' : '+';
|
||||||
|
var tx = btn.querySelector('.watchlist-text'); if (tx) tx.textContent = on ? 'In Watchlist' : 'Add to Watchlist';
|
||||||
|
}
|
||||||
function togglePlaylistFollow(btn) {
|
function togglePlaylistFollow(btn) {
|
||||||
if (!lastPlaylist) return;
|
if (!lastPlaylist) return;
|
||||||
var on = btn.classList.contains('vyt-follow--on');
|
var on = btn.classList.contains('watching');
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
var done = function () { btn.disabled = false; document.dispatchEvent(new CustomEvent('soulsync:video-wishlist-changed')); };
|
var done = function () { btn.disabled = false; document.dispatchEvent(new CustomEvent('soulsync:video-wishlist-changed')); };
|
||||||
if (on) {
|
if (on) {
|
||||||
VideoYoutube.unfollowPlaylist(lastPlaylist.playlist_id).then(function () {
|
VideoYoutube.unfollowPlaylist(lastPlaylist.playlist_id).then(function () {
|
||||||
btn.classList.remove('vyt-follow--on'); btn.innerHTML = '+ Follow'; done();
|
setPlBtn(btn, false); done();
|
||||||
}).catch(function () { btn.disabled = false; });
|
}).catch(function () { btn.disabled = false; });
|
||||||
} else {
|
} else {
|
||||||
VideoYoutube.followPlaylist(lastPlaylist).then(function (d) {
|
VideoYoutube.followPlaylist(lastPlaylist).then(function (d) {
|
||||||
if (d && d.success) {
|
if (d && d.success) {
|
||||||
btn.classList.add('vyt-follow--on'); btn.innerHTML = '✓ Following';
|
setPlBtn(btn, true);
|
||||||
if (typeof showToast === 'function')
|
if (typeof showToast === 'function')
|
||||||
showToast('Added ' + lastPlaylist.title + ' to watchlist', 'success');
|
showToast('Added ' + lastPlaylist.title + ' to watchlist', 'success');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,11 @@
|
||||||
'<span class="vyt-chip-title">' + esc(pl.title) + '</span>' +
|
'<span class="vyt-chip-title">' + esc(pl.title) + '</span>' +
|
||||||
(sub.length ? '<span class="vyt-chip-sub">' + sub.join(' · ') + '</span>' : '') +
|
(sub.length ? '<span class="vyt-chip-sub">' + sub.join(' · ') + '</span>' : '') +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<button class="vyt-follow' + (following ? ' vyt-follow--on' : '') + '" type="button" ' +
|
'<button class="library-artist-watchlist-btn' + (following ? ' watching' : '') + '" type="button" ' +
|
||||||
'data-vyt-follow-playlist>' + (following ? '✓ Following' : '+ Follow') + '</button>' +
|
'data-vyt-follow-playlist>' +
|
||||||
|
'<span class="watchlist-icon">' + (following ? '✓' : '+') + '</span>' +
|
||||||
|
'<span class="watchlist-text">' + (following ? 'In Watchlist' : 'Add to Watchlist') + '</span>' +
|
||||||
|
'</button>' +
|
||||||
'</div></div>';
|
'</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue