Fix #792: sync UI shadowed the new sync-mode setting (forced 'replace')

The reconcile setting never took effect: startPlaylistSync always sent
sync_mode (defaulting to 'replace' from the per-playlist <select>) AND clamped
any non-replace/append value back to 'replace' — so 'reconcile' could never be
sent and the global Settings value was always overridden. The per-server Plex
reconcile code was never even reached; replace ran and re-pushed the poster.

- Per-playlist select now defaults to 'Sync mode: default' (empty) which defers
  to Settings > Playlist sync mode, and gains a 'Reconcile' option for an
  explicit per-sync override.
- startPlaylistSync sends '' (not 'replace') when no explicit choice, so the
  backend uses the configured default; clamp now allows reconcile.
  (Other callers already sent no sync_mode, so they pick up the setting too.)
This commit is contained in:
BoulderBadgeDad 2026-06-04 15:27:00 -07:00
parent 939c660498
commit b105372d70
2 changed files with 11 additions and 6 deletions

View file

@ -4401,12 +4401,15 @@ async function startPlaylistSync(playlistId, syncModeOverride = null) {
let syncMode = syncModeOverride;
if (!syncMode) {
const modeSelect = document.getElementById(`sync-mode-${playlistId}`);
syncMode = (modeSelect && modeSelect.value) || 'replace';
// Empty value = "use the Settings default" — send nothing so the
// backend falls back to playlist_sync.mode (#792). Don't hardcode
// 'replace' here or it shadows the global setting.
syncMode = (modeSelect && modeSelect.value) || '';
}
if (syncMode !== 'replace' && syncMode !== 'append') {
syncMode = 'replace';
if (syncMode && !['replace', 'reconcile', 'append'].includes(syncMode)) {
syncMode = '';
}
console.log(`🚀 [${new Date().toTimeString().split(' ')[0]}] Starting sync for playlist: ${playlistId} (mode: ${syncMode})`);
console.log(`🚀 [${new Date().toTimeString().split(' ')[0]}] Starting sync for playlist: ${playlistId} (mode: ${syncMode || 'default(setting)'})`);
const playlist = spotifyPlaylists.find(p => p.id === playlistId);
if (!playlist) {
console.error(`❌ Could not find playlist data for ID: ${playlistId}`);

View file

@ -1265,8 +1265,10 @@ function playlistModalDownloadSyncFooterHtml(playlistId, options = {}) {
}
return `${downloadBtns}
<select id="sync-mode-${playlistId}" class="playlist-modal-sync-mode" title="Replace overwrites the server playlist; Append only adds new tracks (preserves user-added)">
<option value="replace" selected>Replace</option>
<select id="sync-mode-${playlistId}" class="playlist-modal-sync-mode" title="Default uses your Settings > Playlist sync mode. Replace overwrites the server playlist; Reconcile edits it in place (keeps custom image/description); Append only adds new tracks.">
<option value="" selected>Sync mode: default</option>
<option value="replace">Replace</option>
<option value="reconcile">Reconcile (keep image/desc)</option>
<option value="append">Append only</option>
</select>
<button id="sync-btn-${playlistId}" class="playlist-modal-btn playlist-modal-btn-primary" onclick="startPlaylistSync('${playlistId}')" ${isSyncing ? 'disabled' : ''}>${isSyncing ? '⏳ Syncing...' : 'Sync Playlist'}</button>`;