2026-03-20 20:06:21 +02:00
|
|
|
import { app, ipcMain, shell } from 'electron';
|
|
|
|
|
import { IPC_CHANNELS } from './channels';
|
2026-04-02 11:17:49 +05:30
|
|
|
import {
|
|
|
|
|
selectFolder,
|
|
|
|
|
addWatchedFolder,
|
|
|
|
|
removeWatchedFolder,
|
|
|
|
|
getWatchedFolders,
|
|
|
|
|
getWatcherStatus,
|
|
|
|
|
pauseWatcher,
|
|
|
|
|
resumeWatcher,
|
|
|
|
|
} from '../modules/folder-watcher';
|
2026-03-20 20:06:21 +02:00
|
|
|
|
|
|
|
|
export function registerIpcHandlers(): void {
|
|
|
|
|
ipcMain.on(IPC_CHANNELS.OPEN_EXTERNAL, (_event, url: string) => {
|
|
|
|
|
try {
|
|
|
|
|
const parsed = new URL(url);
|
|
|
|
|
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
|
|
|
|
shell.openExternal(url);
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// invalid URL — ignore
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.GET_APP_VERSION, () => {
|
|
|
|
|
return app.getVersion();
|
|
|
|
|
});
|
2026-04-02 11:17:49 +05:30
|
|
|
|
|
|
|
|
// Folder sync handlers
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_SELECT_FOLDER, () => selectFolder());
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_ADD_FOLDER, (_event, config) =>
|
|
|
|
|
addWatchedFolder(config)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_REMOVE_FOLDER, (_event, folderPath: string) =>
|
|
|
|
|
removeWatchedFolder(folderPath)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_GET_FOLDERS, () => getWatchedFolders());
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_GET_STATUS, () => getWatcherStatus());
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_PAUSE, () => pauseWatcher());
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.FOLDER_SYNC_RESUME, () => resumeWatcher());
|
2026-03-20 20:06:21 +02:00
|
|
|
}
|