diff --git a/src/app.js b/src/app.js index d9ff134c..4a30e08b 100644 --- a/src/app.js +++ b/src/app.js @@ -1,14 +1,14 @@ -import "./stylesheets/main.css"; +import './stylesheets/main.css'; -import "./helpers/context_menu.js"; -import "./helpers/external_links.js"; +import './helpers/context_menu.js'; +import './helpers/external_links.js'; const state = { loaded: false }; -import { remote } from "electron"; -import jetpack from "fs-jetpack"; +import { remote } from 'electron'; +import jetpack from 'fs-jetpack'; const app = remote.app; const appDir = jetpack.cwd(app.getAppPath()); @@ -22,7 +22,7 @@ androidMessagesWebview.addEventListener('did-start-loading', () => { if (permission === 'notifications') { - return callback(true) // Approve + return callback(true); // Approve } // if (!url.startsWith('https://my-website.com')) { diff --git a/src/background.js b/src/background.js index 6c773a43..70942f53 100644 --- a/src/background.js +++ b/src/background.js @@ -3,23 +3,22 @@ // It doesn't have any windows which you can see on screen, but we can open // window from here. -import path from "path"; -import url from "url"; -import { app, Menu } from "electron"; +import path from 'path'; +import url from 'url'; +import { app, Menu } from 'electron'; import { autoUpdater } from 'electron-updater'; -import { appMenuTemplate } from './menu/app_menu_template'; -import { devMenuTemplate } from "./menu/dev_menu_template"; -import { editMenuTemplate } from "./menu/edit_menu_template"; +import { baseMenuTemplate } from './menu/base_menu_template'; +import { devMenuTemplate } from './menu/dev_menu_template'; import { helpMenuTemplate } from './menu/help_menu_template'; -import createWindow from "./helpers/window"; +import createWindow from './helpers/window'; // Special module holding environment variables which you declared // in config/env_xxx.json file. -import env from "env"; +import env from 'env'; const setApplicationMenu = () => { - const menus = [appMenuTemplate, editMenuTemplate]; - if (env.name !== "production") { + const menus = baseMenuTemplate; + if (env.name !== 'production') { menus.push(devMenuTemplate); } menus.push(helpMenuTemplate); @@ -29,33 +28,33 @@ const setApplicationMenu = () => { // Save userData in separate folders for each environment. // Thanks to this you can use production and development versions of the app // on same machine like those are two separate apps. -if (env.name !== "production") { - const userDataPath = app.getPath("userData"); - app.setPath("userData", `${userDataPath} (${env.name})`); +if (env.name !== 'production') { + const userDataPath = app.getPath('userData'); + app.setPath('userData', `${userDataPath} (${env.name})`); } -app.on("ready", () => { +app.on('ready', () => { setApplicationMenu(); autoUpdater.checkForUpdatesAndNotify(); - const mainWindow = createWindow("main", { + const mainWindow = createWindow('main', { width: 1100, height: 800 }); mainWindow.loadURL( url.format({ - pathname: path.join(__dirname, "app.html"), - protocol: "file:", + pathname: path.join(__dirname, 'app.html'), + protocol: 'file:', slashes: true }) ); - if (env.name === "development") { + if (env.name === 'development') { mainWindow.openDevTools(); } }); -app.on("window-all-closed", () => { +app.on('window-all-closed', () => { app.quit(); }); diff --git a/src/menu/app_menu_template.js b/src/menu/app_menu_template.js index 0cd61c6b..7cd2b8d7 100644 --- a/src/menu/app_menu_template.js +++ b/src/menu/app_menu_template.js @@ -1,28 +1,21 @@ import { app } from 'electron'; -import { IS_MAC } from '../constants'; import { aboutMenu } from './items/about'; // This is the "Application" menu, which is only used on macOS -let appMenuTemplate = null; - -if (IS_MAC) { - appMenuTemplate = { - label: 'Android Messages', - submenu: [, - { - label: 'About Android Messages Desktop', - click: () => aboutMenu() - }, - { - type: 'separator', - }, - { - label: 'Quit', - accelerator: 'Command+Q', - click: () => app.quit(), - } - ] - }; -} - -export { appMenuTemplate }; +export const appMenuTemplate = { + label: 'Android Messages', + submenu: [, + { + label: 'About Android Messages Desktop', + click: () => aboutMenu() + }, + { + type: 'separator', + }, + { + label: 'Quit', + accelerator: 'Command+Q', + click: () => app.quit(), + } + ] +}; diff --git a/src/menu/base_menu_template.js b/src/menu/base_menu_template.js new file mode 100644 index 00000000..8bdf67b3 --- /dev/null +++ b/src/menu/base_menu_template.js @@ -0,0 +1,11 @@ +import { appMenuTemplate } from './app_menu_template'; +import { editMenuTemplate } from './edit_menu_template'; +import { IS_MAC } from '../constants'; + +const baseMenuTemplate = [editMenuTemplate]; + +if (IS_MAC) { + baseMenuTemplate.unshift(appMenuTemplate); +} + +export { baseMenuTemplate }; diff --git a/src/menu/help_menu_template.js b/src/menu/help_menu_template.js index cecf985e..bdc9a044 100644 --- a/src/menu/help_menu_template.js +++ b/src/menu/help_menu_template.js @@ -3,11 +3,11 @@ import { IS_MAC } from '../constants'; import { aboutMenu } from './items/about'; export const helpMenuTemplate = { - label: "Help", + label: 'Help', submenu: [ { - label: "Learn More", - click: () => shell.openExternal('https://google.com') + label: 'Learn More', + click: () => shell.openExternal('https://github.com/chrisknepper/android-messages-desktop/') } ] };