import { Channel } from '../../shared/state/channels' ; import type { Middleware } from '../../shared/state/model' ; import { pickerWindow , prefsWindow } from '../windows' ; /**
 * Pass actions between main and renderers
 */ export const busMiddleware = ( ) : Middleware => ( ) => ( next ) => ( action ) => { /**
     * Move to next middleware
     */ const result = next ( action ) ; if ( action . meta ?. channel === Channel . MAIN ) { pickerWindow ?. webContents . send ( Channel . MAIN , action ) ; prefsWindow ?. webContents . send ( Channel . MAIN , action ) ; } else if ( action . meta ?. channel === Channel . PREFS ) { pickerWindow ?. webContents . send ( Channel . MAIN , action ) ; } else if ( action . meta ?. channel === Channel . PICKER ) { prefsWindow ?. webContents . send ( Channel . MAIN , action ) ; } return result ; } ;