1
0

Remove redundant code and simplify folder addition logic in main.js

This commit is contained in:
2025-05-25 06:11:32 +02:00
parent fbfde5d17e
commit 3eb6fca935

35
main.js
View File

@@ -231,7 +231,6 @@ function stopMonitoringWatcher(folderPath) {
}
}
// ---- Rewrite Git Messages with LLM generated messages ----
// ---- 1. Commits & Diffs für LLM sammeln ----
@@ -776,38 +775,6 @@ function buildTrayMenu() {
ipcMain.handle('get-folders', () => store.get('folders'));
// (1) Die Kernfunktion
async function addFolderByPath(newFolder) {
await initGitRepo(newFolder);
let folders = store.get('folders') || [];
let folderObj = folders.find(f => f.path === newFolder);
if (!folderObj) {
folderObj = { path: newFolder, monitoring: true, linesChanged: 0, llmCandidates: [] };
folders.push(folderObj);
store.set('folders', folders);
}
store.set('selected', newFolder);
watchRepo(newFolder, win);
startMonitoringWatcher(newFolder, win);
return store.get('folders');
}
// (2) Die IPC-Handler anpassen:
ipcMain.handle('add-folder', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog({
properties: ['openDirectory']
});
if (canceled || !filePaths[0]) {
return store.get('folders');
}
return await addFolderByPath(filePaths[0]);
});
ipcMain.handle('add-folder-by-path', async (_e, folderPath) => {
return await addFolderByPath(folderPath);
});
// Ordner hinzufügen: Open-Dialog, init, Store-Update, watchen, monitoren
ipcMain.handle('add-folder', async () => {
const { canceled, filePaths } = await dialog.showOpenDialog({
@@ -817,8 +784,6 @@ function buildTrayMenu() {
return store.get('folders');
}
const newFolder = filePaths[0];
await initGitRepo(newFolder);
// HEAD-Hash holen