2022-03-16 09:49:48 +00:00
|
|
|
import { ipcMain, Menu, shell } from 'electron';
|
|
|
|
import { Main } from '../main';
|
2022-03-31 07:33:58 +00:00
|
|
|
import { IPC_MESSAGES } from '../utils/messages';
|
2023-06-22 06:34:32 +00:00
|
|
|
import { emitMainProcessError } from 'backend/helpers';
|
2022-03-16 09:49:48 +00:00
|
|
|
|
|
|
|
export default function registerIpcMainMessageListeners(main: Main) {
|
|
|
|
ipcMain.on(IPC_MESSAGES.OPEN_MENU, (event) => {
|
|
|
|
if (event.sender === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const menu = Menu.getApplicationMenu();
|
|
|
|
if (menu === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.popup({ window: main.mainWindow! });
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.on(IPC_MESSAGES.RELOAD_MAIN_WINDOW, () => {
|
|
|
|
main.mainWindow!.reload();
|
|
|
|
});
|
|
|
|
|
2023-06-21 10:38:39 +00:00
|
|
|
ipcMain.on(IPC_MESSAGES.OPEN_EXTERNAL, (_, link: string) => {
|
2023-06-22 06:34:32 +00:00
|
|
|
shell.openExternal(link).catch((err) => emitMainProcessError(err));
|
2022-03-16 09:49:48 +00:00
|
|
|
});
|
|
|
|
|
2023-06-21 10:38:39 +00:00
|
|
|
ipcMain.on(IPC_MESSAGES.SHOW_ITEM_IN_FOLDER, (_, filePath: string) => {
|
2022-03-16 09:49:48 +00:00
|
|
|
return shell.showItemInFolder(filePath);
|
|
|
|
});
|
|
|
|
}
|