'use strict'
const {BrowserWindow} = require('electron')
const {icon} = require('./platform-specific.js')
let mainWindow = null

const getMainWindow = () => mainWindow

const openMainWindow = () => {
  if (mainWindow) return
  mainWindow = new BrowserWindow({icon})
  mainWindow.loadURL('https://lichess.org')
  mainWindow.on('closed', () => { mainWindow = null })
}

const closeMainWindow = () =>
  mainWindow && mainWindow.close()

const toggleMainWindow = () =>
  mainWindow ? openMainWindow() : closeMainWindow()

const getWindowCount = () =>
  BrowserWindow.getAllWindows().length

module.exports = {
  getMainWindow,
  openMainWindow,
  closeMainWindow,
  toggleMainWindow,
  getWindowCount
}

@@ -473,20 +473,21 @@
 indow ? 
-open
+close
 MainWind
@@ -493,21 +493,20 @@
 dow() : 
-close
+open
 MainWind

Fix toggleMainWindow()