fix: server push status NameError + discover icons as thumbnails

- Fix NameError in both completion handlers: 'database' was not defined
  at module scope, replaced with get_database() call
- Add playlist_id and playlist_name to download_missing batch dicts
  so push prefix check works for those code paths
- Replace generic music note placeholder with playlist-type emojis
  in batch history (Fresh Tape=note, Archives=books, etc.)
- Add source-based fallback icons for mirrored/wishlist/album entries
This commit is contained in:
JohnBaumb 2026-04-23 12:05:37 -07:00
parent 038a0189a4
commit 016e8a4c16
3 changed files with 25 additions and 6 deletions

View file

@ -28875,7 +28875,7 @@ def _on_download_completed(batch_id, task_id, success=True):
'listenbrainz_', 'beatport_',
)
if playlist_id and playlist_id.startswith(_push_prefixes):
database.update_sync_history_push_status(batch_id, 'pending')
get_database().update_sync_history_push_status(batch_id, 'pending')
threading.Thread(
target=_push_playlist_to_server,
args=(batch_id, batch),
@ -31148,6 +31148,8 @@ def start_playlist_missing_downloads(playlist_id):
'active_count': 0,
'max_concurrent': _get_max_concurrent(),
'queue_index': 0,
'playlist_id': playlist_id,
'playlist_name': playlist_name,
# Track state management (replicating sync.py)
'permanently_failed_tracks': [],
'cancelled_tracks': set(),
@ -32285,7 +32287,7 @@ def _check_batch_completion_v2(batch_id):
'listenbrainz_', 'beatport_',
)
if playlist_id and playlist_id.startswith(_push_prefixes):
database.update_sync_history_push_status(batch_id, 'pending')
get_database().update_sync_history_push_status(batch_id, 'pending')
threading.Thread(
target=_push_playlist_to_server,
args=(batch_id, batch),
@ -33691,6 +33693,8 @@ def start_missing_downloads():
'active_count': 0,
'max_concurrent': _get_max_concurrent(),
'queue_index': 0,
'playlist_id': playlist_id,
'playlist_name': 'Legacy Modal',
# Track state management (replicating sync.py)
'permanently_failed_tracks': [],
'cancelled_tracks': set(),

View file

@ -2881,10 +2881,24 @@ function _adlRenderBatchHistory() {
const dotTip = dotSource ? `Source: ${dotSource}` : 'Unknown source';
const histDot = `<span class="adl-batch-history-dot" style="background:rgba(${dotColor}, 0.6)" title="${dotTip}"></span>`;
// Thumbnail with placeholder fallback
// Thumbnail with playlist-type icon fallback
let placeholderIcon = '♫';
const pName = (h.playlist_name || '').toLowerCase();
if (pName.includes('fresh tape') || pName.includes('release radar')) placeholderIcon = '🎵';
else if (pName.includes('archives') || pName.includes('discovery weekly')) placeholderIcon = '📚';
else if (pName.includes('seasonal')) placeholderIcon = '🌿';
else if (pName.includes('popular picks')) placeholderIcon = '🔥';
else if (pName.includes('hidden gems')) placeholderIcon = '💎';
else if (pName.includes('discovery shuffle')) placeholderIcon = '🔀';
else if (pName.includes('familiar fav')) placeholderIcon = '❤️';
else if (pName.includes('jam')) placeholderIcon = '🎸';
else if (pName.includes('explor')) placeholderIcon = '🔭';
else if (dotSource === 'mirrored' || dotSource === 'youtube') placeholderIcon = '🔗';
else if (dotSource === 'wishlist') placeholderIcon = '⭐';
else if (dotSource === 'album') placeholderIcon = '💿';
const thumb = h.thumb_url
? `<img src="${_adlEsc(h.thumb_url)}" class="adl-batch-history-thumb" loading="lazy" onerror="this.classList.add('adl-batch-history-thumb-placeholder');this.removeAttribute('src')">`
: `<span class="adl-batch-history-thumb adl-batch-history-thumb-placeholder"></span>`;
? `<img src="${_adlEsc(h.thumb_url)}" class="adl-batch-history-thumb" loading="lazy" data-icon="${placeholderIcon}" onerror="var s=document.createElement('span');s.className='adl-batch-history-thumb adl-batch-history-thumb-placeholder';s.textContent=this.dataset.icon;this.parentNode.replaceChild(s,this)">`
: `<span class="adl-batch-history-thumb adl-batch-history-thumb-placeholder">${placeholderIcon}</span>`;
// Server push status indicator
let pushBadge = '';

View file

@ -57206,9 +57206,10 @@ body.reduce-effects *::after {
justify-content: center;
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.06);
font-size: 14px;
}
.adl-batch-history-thumb-placeholder::after {
.adl-batch-history-thumb-placeholder:empty::after {
content: '♫';
font-size: 12px;
color: rgba(255, 255, 255, 0.2);