Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Menus #895

Merged
merged 16 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"release-mas-dev": "build --publish never --mac mas-dev --c.mac.provisioningProfile=Development.provisionprofile",
"lint": "eslint src",
"pretest": "gulp build-unit-tests --env=test",
"test": "electron-mocha app/specs.js.autogenerated --renderer --require source-map-support/register",
"test-main": "electron-mocha --require source-map-support/register app/main.specs.js",
"test-renderer": "electron-mocha --require source-map-support/register --renderer app/renderer.specs.js",
"test": "npm-run-all test-main test-renderer",
"coverage": "npm test -- -R scripts/istanbul-reporter",
"pree2e": "gulp build-e2e-tests --env=test",
"e2e": "mocha app/e2e.js.autogenerated --require source-map-support/register"
Expand Down Expand Up @@ -55,10 +57,12 @@
"istanbul": "^0.4.5",
"minimist": "^1.2.0",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"rollup": "^0.66.1",
"rollup-plugin-istanbul": "^2.0.1",
"rollup-plugin-json": "^3.1.0",
"run-sequence": "^2.2.1",
"sinon": "^6.3.4",
"spectron": "^4.0.0"
},
"devEngines": {
Expand Down
2 changes: 0 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ Bugsnag.metaData = {

Bugsnag.appVersion = app.getVersion();

app.setAppUserModelId('chat.rocket');

window.$ = window.jQuery = require('./vendor/jquery-3.1.1');
start();
53 changes: 19 additions & 34 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ import querystring from 'querystring';
import url from 'url';
import jetpack from 'fs-jetpack';
import idle from '@paulcbetts/system-idle-time';
import { app, ipcMain, BrowserWindow, Menu } from 'electron';
import { app, ipcMain, Menu } from 'electron';

import autoUpdate from './background/autoUpdate';
import certificate from './background/certificate';
import { addServer, createMainWindow, getMainWindow } from './background/mainWindow';
import menus from './background/menus';
import './background/screenshare';

import i18n from './i18n/index.js';
import env from './env';

export { default as showAboutDialog } from './background/aboutDialog';
export { default as remoteServers } from './background/servers';
export { default as certificate } from './background/certificate';
export { certificate, menus };

process.env.GOOGLE_API_KEY = 'AIzaSyADqUh_c1Qhji3Cp1NE43YrcpuPkmhXD-c';

const isMacOS = process.platform === 'darwin';

const unsetDefaultApplicationMenu = () => {
if (!isMacOS) {
if (process.platform !== 'darwin') {
Menu.setApplicationMenu(null);
return;
}

const emptyMenuTemplate = [{
submenu: [
{
label: i18n.__('Quit_App', app.getName()),
label: i18n.__('&Quit %s', app.getName()),
accelerator: 'CommandOrControl+Q',
click() {
app.quit();
Expand Down Expand Up @@ -85,46 +85,31 @@ app.on('open-url', (event, url) => {
addServers([url]);
});

app.on('window-all-closed', () => {
app.quit();
});

if (!app.isDefaultProtocolClient('rocketchat')) {
app.setAsDefaultProtocolClient('rocketchat');
}

app.setAppUserModelId('chat.rocket');
if (process.platform === 'linux') {
app.disableHardwareAcceleration();
}

app.on('ready', () => {
unsetDefaultApplicationMenu();
setUserDataPath();
migrateOlderVersionUserData();

if (!app.isDefaultProtocolClient('rocketchat')) {
app.setAsDefaultProtocolClient('rocketchat');
}

createMainWindow();

getMainWindow().then((mainWindow) => certificate.initWindow(mainWindow));

autoUpdate();
});

app.on('window-all-closed', () => {
app.quit();
});

ipcMain.on('getSystemIdleTime', (event) => {
event.returnValue = idle.getIdleTime();
});

ipcMain.on('show-about-dialog', () => {
getMainWindow().then((mainWindow) => {
const win = new BrowserWindow({
title: i18n.__('About', app.getName()),
parent: mainWindow,
width: 400,
height: 300,
type: 'toolbar',
resizable: false,
maximizable: false,
minimizable: false,
center: true,
show: false,
});
win.setMenuBarVisibility(false);
win.once('ready-to-show', () => win.show());
win.loadURL(`file://${ __dirname }/public/about.html`);
});
});
22 changes: 22 additions & 0 deletions src/background/aboutDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { app, BrowserWindow } from 'electron';
import { getMainWindow } from './mainWindow';
import i18n from '../i18n/index.js';

export default async() => {
const mainWindow = await getMainWindow();
const win = new BrowserWindow({
title: i18n.__('About %s', app.getName()),
parent: mainWindow,
width: 400,
height: 300,
type: 'toolbar',
resizable: false,
maximizable: false,
minimizable: false,
center: true,
show: false,
});
win.setMenuBarVisibility(false);
win.once('ready-to-show', () => win.show());
win.loadURL(`file://${ __dirname }/public/about.html`);
};
Loading