Fix sync completion not reaching UI after WebSocket reconnect
This commit is contained in:
parent
8b3b82702a
commit
2ef0c75a25
2 changed files with 17 additions and 1 deletions
|
|
@ -22925,7 +22925,12 @@ def _run_sync_task(playlist_id, playlist_name, tracks_json, automation_id=None):
|
|||
|
||||
# Run the sync (this is a blocking call within this thread)
|
||||
result = run_async(sync_service.sync_playlist(playlist, download_missing=False))
|
||||
|
||||
|
||||
# Clear progress callback immediately to prevent race condition where a
|
||||
# late-firing progress callback overwrites the "finished" state below
|
||||
if sync_service:
|
||||
sync_service.clear_progress_callback(playlist.name)
|
||||
|
||||
sync_duration = (time.time() - sync_start_time) * 1000
|
||||
total_duration = (time.time() - task_start_time) * 1000
|
||||
print(f"⏱️ [TIMING] Sync completed at {time.strftime('%H:%M:%S')} (sync: {sync_duration:.1f}ms, total: {total_duration:.1f}ms)")
|
||||
|
|
|
|||
|
|
@ -147,6 +147,17 @@ function initializeWebSocket() {
|
|||
console.log('WebSocket connected');
|
||||
socketConnected = true;
|
||||
resubscribeDownloadBatches();
|
||||
// Re-subscribe to any active sync/discovery rooms after reconnect
|
||||
const activeSyncIds = Object.keys(_syncProgressCallbacks);
|
||||
if (activeSyncIds.length > 0) {
|
||||
socket.emit('sync:subscribe', { playlist_ids: activeSyncIds });
|
||||
console.log('🔄 Re-subscribed to sync rooms:', activeSyncIds);
|
||||
}
|
||||
const activeDiscoveryIds = Object.keys(_discoveryProgressCallbacks);
|
||||
if (activeDiscoveryIds.length > 0) {
|
||||
socket.emit('discovery:subscribe', { ids: activeDiscoveryIds });
|
||||
console.log('🔄 Re-subscribed to discovery rooms:', activeDiscoveryIds);
|
||||
}
|
||||
// Join profile room for scoped watchlist/wishlist count updates
|
||||
if (currentProfile) {
|
||||
socket.emit('profile:join', { profile_id: currentProfile.id });
|
||||
|
|
|
|||
Loading…
Reference in a new issue