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:
BoulderBadgeDad 2026-06-17 20:42:30 -07:00
parent ef3d4cfdb4
commit e141e3dcbd
2 changed files with 14 additions and 6 deletions

View file

@ -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) {
if (!lastPlaylist) return;
var on = btn.classList.contains('vyt-follow--on');
var on = btn.classList.contains('watching');
btn.disabled = true;
var done = function () { btn.disabled = false; document.dispatchEvent(new CustomEvent('soulsync:video-wishlist-changed')); };
if (on) {
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; });
} else {
VideoYoutube.followPlaylist(lastPlaylist).then(function (d) {
if (d && d.success) {
btn.classList.add('vyt-follow--on'); btn.innerHTML = '✓ Following';
setPlBtn(btn, true);
if (typeof showToast === 'function')
showToast('Added ' + lastPlaylist.title + ' to watchlist', 'success');
}

View file

@ -127,8 +127,11 @@
'<span class="vyt-chip-title">' + esc(pl.title) + '</span>' +
(sub.length ? '<span class="vyt-chip-sub">' + sub.join(' · ') + '</span>' : '') +
'</div>' +
'<button class="vyt-follow' + (following ? ' vyt-follow--on' : '') + '" type="button" ' +
'data-vyt-follow-playlist>' + (following ? '✓ Following' : '+ Follow') + '</button>' +
'<button class="library-artist-watchlist-btn' + (following ? ' watching' : '') + '" type="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>';
}