import { ipcRenderer } from 'electron' ; import IPC_EVENTS from './ipc-events' ; export function withLeadingZero ( val ) { return `${ val >= 0 && val < 10 ? '0' : '' }${ val }` ; } export function formatDateTo24Time ( date ) { const hours = date . getHours ( ) ; const minutes = date . getMinutes ( ) ; return `${ withLeadingZero ( hours ) }:${ withLeadingZero ( minutes ) }` ; } export function isEmptyObject ( obj ) { return Object . keys ( obj ) . length === 0 && obj . constructor === Object ; } export function catcher < T = any , E = Error > ( promise ) { return promise . then < [ T , null ] > ( ( data ) => [ data , null ] ) . catch < [ undefined , E ] > ( ( err ) => { return [ undefined , err ] ; } ) ; } export function handleExtLinkClick ( url , event ) { event . preventDefault ( ) ; ipcRenderer . send ( IPC_EVENTS . OPEN_BROWSER_FOR_URL , url ) ; }