diff --git a/lib/upload-manager.js b/lib/upload-manager.js index 35078ea..85d4197 100644 --- a/lib/upload-manager.js +++ b/lib/upload-manager.js @@ -75,7 +75,7 @@ class UploadManager extends EventEmitter { const settings = { ...DEFAULT_SETTINGS, ...(this.hosterSettings[hoster] || {}) }; const globalLimit = this._getGlobalParallelLimit(); if (this.globalSettings.scaleParallelUploads && globalLimit > 0) { - settings.parallelCount = Math.max(settings.parallelCount || 1, globalLimit); + settings.parallelCount = Math.min(settings.parallelCount || 1, globalLimit); } return settings; } diff --git a/renderer/app.js b/renderer/app.js index 358b3ba..7e4b40a 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -130,6 +130,18 @@ async function init() { addPathsToQueue(paths); }); + // Remote client count updates (registered once, not per renderSettings call) + window.api.onRemoteClientCount(() => { + const el = document.getElementById('remoteConnectionStatus'); + if (el && el.style.color === 'rgb(16, 185, 129)') { + window.api.remoteStatus().then(status => { + if (status.running) { + el.textContent = `Aktiv auf Port ${status.port} — ${status.clientCount} Client(s) verbunden`; + } + }).catch(() => {}); + } + }); + window.api.debugLog('init complete, all listeners registered'); // Restore always-on-top state @@ -2195,17 +2207,7 @@ function renderSettings() { } }).catch(() => {}); - // Live client count updates - window.api.onRemoteClientCount((count) => { - const el = document.getElementById('remoteConnectionStatus'); - if (el && el.style.color === 'rgb(16, 185, 129)') { - window.api.remoteStatus().then(status => { - if (status.running) { - el.textContent = `Aktiv auf Port ${status.port} — ${status.clientCount} Client(s) verbunden`; - } - }).catch(() => {}); - } - }); + // Live client count updates (listener registered once in init, not here) // --- Backup Panel --- const backupPanel = document.createElement('div'); @@ -3067,6 +3069,12 @@ function sortHistoryRows(rows) { // Flush pending queue state on window close (sync IPC — blocks until save completes) window.addEventListener('beforeunload', () => { + // Flush pending settings save if user changed settings right before closing + if (settingsSaveTimer) { + clearTimeout(settingsSaveTimer); + settingsSaveTimer = null; + try { saveSettings(); } catch {} + } clearTimeout(queuePersistTimer); queuePersistTimer = null; const globalSettings = {