From fa5fc95356a57a02cb38d9723ad9c28e9e191812 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 25 May 2025 06:04:30 +0200 Subject: [PATCH] Enable monitoring toggle only if folder does not need relocation --- main.js | 96 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/main.js b/main.js index 750146a..99a8cc6 100644 --- a/main.js +++ b/main.js @@ -664,55 +664,61 @@ async function main() { const tray = createTray(win); // --- Context Menu bauen --- - function buildTrayMenu() { - const folders = store.get('folders') || []; - const monitoringActive = folders.some(f => f.monitoring); +function buildTrayMenu() { + const folders = store.get('folders') || []; + const monitoringActive = folders.some(f => f.monitoring); - return Menu.buildFromTemplate([ - { label: 'Auto-Git öffnen', click: () => { win.show(); win.focus(); } }, - { type: 'separator' }, - ...folders.map(f => ({ - label: `${f.monitoring ? '🟢' : '🔴'} ${path.basename(f.path)}`, - submenu: [ - { - label: f.monitoring ? 'Monitoring stoppen' : 'Monitoring starten', - click: () => { - win.webContents.send('tray-toggle-monitoring', f.path); // Renderer kann dann toggeln - } - }, - { - label: 'Ordner entfernen', - click: () => { - win.webContents.send('tray-remove-folder', f.path); + return Menu.buildFromTemplate([ + { label: 'Auto-Git öffnen', click: () => { win.show(); win.focus(); } }, + { type: 'separator' }, + ...folders.map(f => ({ + label: `${f.monitoring ? '🟢' : '🔴'} ${path.basename(f.path)}`, + submenu: [ + { + label: f.monitoring ? 'Monitoring stoppen' : 'Monitoring starten', + enabled: !f.needsRelocation, // <--- HIER! + click: () => { + if (!f.needsRelocation) { + win.webContents.send('tray-toggle-monitoring', f.path); } + // Optional: Feedback anzeigen, falls doch geklickt wird. + } + }, + { + label: 'Ordner entfernen', + click: () => { + win.webContents.send('tray-remove-folder', f.path); } - ] - })), - { type: 'separator' }, - { - label: 'Neuen Ordner hinzufügen', - click: () => { win.webContents.send('tray-add-folder'); } - }, - { - label: 'Alle Monitorings starten', - click: () => { - folders.forEach(f => { - if (!f.monitoring) win.webContents.send('tray-toggle-monitoring', f.path); - }); } - }, - { - label: 'Alle Monitorings stoppen', - click: () => { - folders.forEach(f => { - if (f.monitoring) win.webContents.send('tray-toggle-monitoring', f.path); - }); - } - }, - { type: 'separator' }, - { label: 'Beenden', click: () => { isQuiting = true; app.quit(); } } - ]); - } + ] + })), + { type: 'separator' }, + { + label: 'Neuen Ordner hinzufügen', + click: () => { win.webContents.send('tray-add-folder'); } + }, + { + label: 'Alle Monitorings starten', + click: () => { + folders.forEach(f => { + if (!f.monitoring && !f.needsRelocation) { + win.webContents.send('tray-toggle-monitoring', f.path); + } + }); + } + }, + { + label: 'Alle Monitorings stoppen', + click: () => { + folders.forEach(f => { + if (f.monitoring) win.webContents.send('tray-toggle-monitoring', f.path); + }); + } + }, + { type: 'separator' }, + { label: 'Beenden', click: () => { isQuiting = true; app.quit(); } } + ]); +} tray.setToolTip('Auto-Git läuft im Hintergrund'); tray.setContextMenu(buildTrayMenu());