2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00
books/main/registerIpcMainMessageListeners.ts
18alantom 4415c04a88 chore: enable typescript eslint rules
- refactor code to satisfy rules (batch 1)
- use ensuredir in build to prevent ENOENT
2023-06-21 16:08:47 +05:30

31 lines
769 B
TypeScript

import { ipcMain, Menu, shell } from 'electron';
import { Main } from '../main';
import { IPC_MESSAGES } from '../utils/messages';
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();
});
ipcMain.on(IPC_MESSAGES.OPEN_EXTERNAL, (_, link: string) => {
shell.openExternal(link);
});
ipcMain.on(IPC_MESSAGES.SHOW_ITEM_IN_FOLDER, (_, filePath: string) => {
return shell.showItemInFolder(filePath);
});
}