import type { AnyAction } from '@reduxjs/toolkit' ; import electron , { app } from 'electron' ; import sleep from 'tings/lib/sleep' ; import { Channel } from '../shared/state/channels' ; import { openedUrl , readiedApp } from './state/actions' ; import { dispatch , getState } from './state/store' ; app . commandLine . appendArgument ( '--enable-features=Metal' ) ; app . on ( 'ready' , ( ) => dispatch ( readiedApp ( ) ) ) ; app . on ( 'before-quit' , ( ) => app . exit ( ) ) ; app . on ( 'open-url' , ( event , url ) => { event . preventDefault ( ) ; const urlOpener = async ( ) => { if ( getState ( ) . data . pickerStarted ) { dispatch ( openedUrl ( url ) ) ; } else { await sleep ( 500 ) ; urlOpener ( ) ; } } ; urlOpener ( ) ; } ) ; /**
 * Enter actions from renderer into main's store's queue
 */ electron . ipcMain . on ( Channel . PREFS , ( _ , action ) => dispatch ( action ) ) ; electron . ipcMain . on ( Channel . PICKER , ( _ , action ) => dispatch ( action ) ) ;