import { app, BrowserWindow } from 'electron'
import { createMainWindow } from './window'
import { registerShortcut } from './shortcut'
import { setupIpc } from './ipc'
import { createTray } from './tray'
import log from 'electron-log'

log.info('App starting...')

app.whenReady().then(() => {
  const win = createMainWindow()
  registerShortcut(win)
  setupIpc(win)
  createTray(win)

  app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) {
      createMainWindow()
    }
  })
})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})
