import { BrowserWindow , globalShortcut , ipcMain } from 'electron' ; import { Settings } from '../background/db' ; import { leap } from './helpers' ; import { createMenu } from './menu' ; function registerShortcuts ( settings , mainWindow ) { const hasView = mainWindow . getBrowserViews ( ) ?. length > 0 ; if ( settings [ 'global-leap' ] === 'true' && hasView ) { globalShortcut . register ( 'CommandOrControl+/' , ( ) => leap ( mainWindow ) ) ; } else { globalShortcut . unregister ( 'CommandOrControl+/' ) ; } } export function start ( mainWindow , menuOptions ) { ipcMain . handle ( 'update-settings' , ( event , settings ) => { registerShortcuts ( settings , mainWindow ) ; createMenu ( { ... menuOptions , settings } ) ; } ) ; }