feat(electron): make typescript for electron work

This commit is contained in:
Johannes Millan 2019-01-18 17:06:22 +01:00
parent ceebd30453
commit b28f6eb3cd
12 changed files with 200 additions and 420 deletions

1
.gitignore vendored
View file

@ -43,3 +43,4 @@ Thumbs.db
# added
build/hub
electron/**/*.js
electron/**/*.js.map

View file

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<g>
<path d="m61.6 32.119a29.578 29.707 0 0 1 -29.578 29.707 29.578 29.707 0 0 1 -29.578 -29.707 29.578 29.707 0 0 1 29.578 -29.707 29.578 29.707 0 0 1 29.578 29.707z" fill="#03a9f4" stroke="#03a9f4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="13.8" stroke-width="4.1943"/>
<path d="m8.8372 32.373 25.726 21.665 25.356-46.561-27.159 34.621z" fill-rule="evenodd"/>
</g>
<svg version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
>
<g>
<path d="m61.6 32.119a29.578 29.707 0 0 1 -29.578 29.707 29.578 29.707 0 0 1 -29.578 -29.707 29.578 29.707 0 0 1 29.578 -29.707 29.578 29.707 0 0 1 29.578 29.707z"
fill="#03a9f4" stroke="#03a9f4" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="13.8"
stroke-width="4.1943"/>
<path d="m8.8372 32.373 25.726 21.665 25.356-46.561-27.159 34.621z" fill-rule="evenodd"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 666 B

After

Width:  |  Height:  |  Size: 565 B

Before After
Before After

View file

@ -2,62 +2,61 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
id="svg3360"
version="1.1"
inkscape:version="0.91 r13725"
viewBox="0 0 64 64"
sodipodi:docname="ico-white.svg">
<defs
id="defs3362" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890873"
inkscape:cx="82.291165"
inkscape:cy="47.350794"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1869"
inkscape:window-height="1056"
inkscape:window-x="51"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata3365">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
id="path3395"
style="fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.46761858;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:13.80000019;stroke-dasharray:none;stroke-opacity:1;fill:#ffffff"
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns="http://www.w3.org/2000/svg"
width="64"
height="64"
id="svg3360"
version="1.1"
inkscape:version="0.91 r13725"
viewBox="0 0 64 64"
sodipodi:docname="ico-white.svg">
<defs
id="defs3362"/>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890873"
inkscape:cx="82.291165"
inkscape:cy="47.350794"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1869"
inkscape:window-height="1056"
inkscape:window-x="51"
inkscape:window-y="24"
inkscape:window-maximized="1"/>
<metadata
id="metadata3365">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
id="path3395"
style="fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.46761858;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:13.80000019;stroke-dasharray:none;stroke-opacity:1;fill:#ffffff"
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before After
Before After

View file

@ -2,62 +2,61 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64"
height="64"
id="svg3360"
version="1.1"
inkscape:version="0.91 r13725"
viewBox="0 0 64 64"
sodipodi:docname="ico.svg">
<defs
id="defs3362" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="69.479799"
inkscape:cy="75.977339"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1869"
inkscape:window-height="1056"
inkscape:window-x="51"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata3365">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
id="path3395"
style="fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.46761858;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:13.80000019;stroke-dasharray:none;stroke-opacity:1"
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns="http://www.w3.org/2000/svg"
width="64"
height="64"
id="svg3360"
version="1.1"
inkscape:version="0.91 r13725"
viewBox="0 0 64 64"
sodipodi:docname="ico.svg">
<defs
id="defs3362"/>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="69.479799"
inkscape:cy="75.977339"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1869"
inkscape:window-height="1056"
inkscape:window-x="51"
inkscape:window-y="24"
inkscape:window-maximized="1"/>
<metadata
id="metadata3365">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
id="path3395"
style="fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.46761858;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:13.80000019;stroke-dasharray:none;stroke-opacity:1"
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

View file

@ -42,7 +42,7 @@ function init(params) {
// Return code 0x1 means we successfully had the name
if (retCode === 1) {
console.log(`Successfully requested service name '${serviceName}'!`)
console.log(`Successfully requested service name '${serviceName}'!`);
proceed();
}
/* Other return codes means various errors, check here
@ -84,28 +84,28 @@ function init(params) {
// Then we need to create the interface implementation (with actual functions)
iface = {
markAsDone: function() {
markAsDone: function () {
checkMainWin();
const mainWin = mainWinMod.getWin();
mainWin.webContents.send('TASK_MARK_AS_DONE');
},
startTask: function() {
startTask: function () {
checkMainWin();
const mainWin = mainWinMod.getWin();
mainWin.webContents.send('TASK_START');
},
pauseTask: function() {
pauseTask: function () {
checkMainWin();
const mainWin = mainWinMod.getWin();
mainWin.webContents.send('TASK_PAUSE');
},
showApp: function() {
showApp: function () {
params.showApp();
},
quitApp: function() {
quitApp: function () {
params.quitApp();
},
emit: function() {
emit: function () {
// no nothing, as usual
}
};
@ -133,7 +133,7 @@ if (!isDBusError) {
errorHandler('DBus: interface not ready yet');
isErrorShownOnce = true;
} else {
iface.emit('taskChanged', taskId + '', taskText + '')
iface.emit('taskChanged', taskId + '', taskText + '');
}
},
updatePomodoro: (isOnBreak, currentSessionTime, currentSessionInitialTime) => {
@ -143,7 +143,7 @@ if (!isDBusError) {
}
if (iface) {
iface.emit('pomodoroUpdate', (isOnBreak ? 1 : 0), currentSessionTime, currentSessionInitialTime)
iface.emit('pomodoroUpdate', (isOnBreak ? 1 : 0), currentSessionTime, currentSessionInitialTime);
} else {
errorHandler('DBus: interface not ready yet');
isErrorShownOnce = true;

View file

@ -44,8 +44,7 @@ function inspectElements() {
const win = BrowserWindow.getFocusedWindow();
const inspect = () => {
// TODO check
// tslint:disable-next-line
win.devToolsWebContents.executeJavaScript('DevToolsAPI.enterInspectElementMode()');
// win.devToolsWebContents.executeJavaScript('DevToolsAPI.enterInspectElementMode()');
};
if (win) {
@ -59,9 +58,9 @@ function inspectElements() {
}
const addExtensionIfInstalled = (name, getPath) => {
const isExtensionInstalled = name => {
const isExtensionInstalled = name_ => {
return BrowserWindow.getDevToolsExtensions &&
{}.hasOwnProperty.call(BrowserWindow.getDevToolsExtensions(), name);
{}.hasOwnProperty.call(BrowserWindow.getDevToolsExtensions(), name_);
};
try {
@ -105,9 +104,6 @@ export const initDebug = (opts, isAddReload) => {
});
app.on('ready', () => {
addExtensionIfInstalled('devtron', name => require(name).path);
addExtensionIfInstalled('electron-react-devtools', name => require(name).path);
localShortcut.register('CmdOrCtrl+Shift+C', inspectElements);
localShortcut.register(isMacOS ? 'Cmd+Alt+I' : 'Ctrl+Shift+I', devTools);
localShortcut.register('F12', devTools);

View file

@ -1,6 +1,6 @@
import { getWin } from './main-window';
export const getGitLog = function(data) {
export const getGitLog = function (data) {
'use strict';
const exec = require('child_process').exec;
@ -8,7 +8,7 @@ export const getGitLog = function(data) {
exec(cmd, {
cwd: data.cwd
}, function(error, stdout) {
}, function (error, stdout) {
const mainWin = getWin();
mainWin.webContents.send('GIT_LOG_RESPONSE', {
stdout: stdout,

View file

@ -45,9 +45,9 @@ async function authenticate(refreshToken) {
});
// TODO check
// tslint:disable-next-line
oauth2Client.refreshToken(refreshToken)
.then(resolve)
.catch(reject);
// oauth2Client.refreshToken(refreshToken)
// .then(resolve)
// .catch(reject);
} else {
const authorizeUrl = oauth2Client.generateAuthUrl({
access_type: 'offline',
@ -78,7 +78,7 @@ function openAuthWindow(url) {
return new Promise((resolve, reject) => {
/* tslint:disable-next-line */
const win = new BrowserWindow(browserWindowParams || {'use-content-size': true});
const win = new BrowserWindow(browserWindowParams || {useContentSize: true});
win.loadURL(url);

View file

@ -3,6 +3,7 @@ import { errorHandler } from './error-handler';
import { join, normalize } from 'path';
import { format } from 'url';
import { getSettings } from './get-settings';
import MenuItemConstructorOptions = Electron.MenuItemConstructorOptions;
let mainWin;
let indicatorMod;
@ -44,17 +45,18 @@ export const createWindow = function (params) {
mainWin.loadURL('http://localhost:4200');
} else {
mainWin = new BrowserWindow({width: 800, height: 600});
mainWin.loadURL(format({
const url = format({
pathname: normalize(join(__dirname, '../dist/index.html')),
protocol: 'file:',
slashes: true,
}, {
});
mainWin.loadURL(url, {
show: false,
webPreferences: {
scrollBounce: true
},
icon: ICONS_FOLDER + '/icon_256x256.png'
}));
});
// mainWin.webContents.openDevTools();
}
// show gracefully
@ -90,51 +92,51 @@ function initWinEventListeners(app, IS_MAC, nestedWinParams) {
});
mainWin.on('close', function (event) {
if (app.isQuiting) {
app.quit();
} else {
event.preventDefault();
// if (app.isQuiting) {
// app.quit();
// } else {
event.preventDefault();
getSettings(mainWin, (appCfg) => {
if (appCfg && appCfg.misc.isConfirmBeforeExit) {
const choice = require('electron').dialog.showMessageBox(mainWin,
{
type: 'question',
buttons: ['Yes', 'No'],
title: 'Confirm',
message: 'Are you sure you want to quit?'
});
if (choice === 1) {
event.preventDefault();
return;
}
getSettings(mainWin, (appCfg) => {
if (appCfg && appCfg.misc.isConfirmBeforeExit) {
const choice = require('electron').dialog.showMessageBox(mainWin,
{
type: 'question',
buttons: ['Yes', 'No'],
title: 'Confirm',
message: 'Are you sure you want to quit?'
});
if (choice === 1) {
event.preventDefault();
return;
}
}
if (!appCfg || !appCfg.misc.isMinimizeToTrayOnExit) {
app.isQuiting = true;
app.quit();
} else {
// handle darwin
if (IS_MAC) {
if (nestedWinParams.isDarwinForceQuit) {
app.isQuiting = true;
app.quit();
} else {
event.preventDefault();
mainWin.hide();
}
if (!appCfg || !appCfg.misc.isMinimizeToTrayOnExit) {
// app.isQuiting = true;
app.quit();
} else {
// handle darwin
if (IS_MAC) {
if (nestedWinParams.isDarwinForceQuit) {
// app.isQuiting = true;
app.quit();
} else {
if (indicatorMod.isRunning()) {
event.preventDefault();
mainWin.hide();
} else {
app.isQuiting = true;
app.quit();
}
event.preventDefault();
mainWin.hide();
}
} else {
// if (indicatorMod.isRunning()) {
// event.preventDefault();
// mainWin.hide();
// } else {
// app.isQuiting = true;
app.quit();
// }
}
});
}
}
});
// }
});
}
@ -162,8 +164,9 @@ function createMenu(quitApp) {
]
}
];
const menuTpl_ = menuTpl as MenuItemConstructorOptions[];
// we need to set a menu to get copy & paste working for mac os x
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTpl));
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTpl_));
}

View file

@ -1,226 +0,0 @@
'use strict';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var electron = require('electron');
var powerSaveBlocker = electron.powerSaveBlocker;
var notifier = require('node-notifier');
//const autoUpdater = require('electron-updater').autoUpdater;
var log = require('electron-log');
var electronLocalshortcut = require('electron-localshortcut');
var CONFIG = require('./CONFIG');
var indicatorMod = require('./indicator');
var mainWinMod = require('./main-window');
var getIdleTime = require('./get-idle-time');
var jira = require('./jira');
var gitLog = require('./git-log');
var googleAuth = require('./google-auth');
var errorHandler = require('./error-handler');
var ICONS_FOLDER = __dirname + '/assets/icons/';
var IS_MAC = process.platform === 'darwin';
var IS_LINUX = process.platform === 'linux';
var DESKTOP_ENV = process.env.DESKTOP_SESSION;
var IS_GNOME = (DESKTOP_ENV === 'gnome' || DESKTOP_ENV === 'gnome-xorg');
var IS_DEV = process.env.NODE_ENV === 'DEV';
if (IS_DEV) {
console.log('Starting in DEV Mode!!!');
}
var app = electron.app;
require('./debug')({ showDevTools: IS_DEV }, IS_DEV);
var mainWin;
var nestedWinParams = { isDarwinForceQuit: false };
// keep app active to keep time tracking running
powerSaveBlocker.start('prevent-app-suspension');
// make it a single instance by closing other instances
app.requestSingleInstanceLock();
app.on('second-instance', function () {
// the callback: only called only for first instance
// we want to show it, when the other starts to try another
if (mainWin) {
showApp();
if (mainWin.isMinimized()) {
mainWin.restore();
}
mainWin.focus();
}
});
//if (shouldQuitBecauseAppIsAnotherInstance) {
// quitAppNow();
// return;
//}
// APP EVENT LISTENERS
// -------------------
app.on('ready', createMainWin);
app.on('ready', createIndicator);
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWin === null) {
createMainWin();
}
else {
showApp();
}
});
var idleInterval;
app.on('ready', function () {
// init time tracking interval
idleInterval = setInterval(idleChecker, CONFIG.IDLE_PING_INTERVAL);
});
app.on('before-quit', function () {
// handle darwin
if (IS_MAC) {
nestedWinParams.isDarwinForceQuit = true;
}
// un-register all shortcuts.
electron.globalShortcut.unregisterAll();
});
// AUTO-UPDATER
// ------------
//app.on('ready', () => {
// // init auto-updates
// log.info('INIT AUTO UPDATES');
// // log.info(autoUpdater.getFeedURL());
// autoUpdater.logger = log;
// autoUpdater.logger.transports.file.level = 'info';
// autoUpdater.checkForUpdatesAndNotify();
//});
//
//autoUpdater.on('update-downloaded', (ev, info) => {
// console.log(ev);
// // Wait 5 seconds, then quit and install
// // In your application, you don't need to wait 5 seconds.
// // You could call autoUpdater.quitAndInstall(); immediately
// setTimeout(function() {
// autoUpdater.quitAndInstall();
// }, 5000)
//});
// FRONTEND EVENTS
// ---------------
electron.ipcMain.on('SHUTDOWN_NOW', quitAppNow);
electron.ipcMain.on('SHUTDOWN', quitApp);
electron.ipcMain.on('EXEC', exec);
electron.ipcMain.on('REGISTER_GLOBAL_SHORTCUT', function (ev, shortcutPassed) {
registerShowAppShortCut(shortcutPassed);
});
electron.ipcMain.on('TOGGLE_DEV_TOOLS', function () {
mainWin.webContents.openDevTools();
});
electron.ipcMain.on('JIRA', function (ev, request) {
jira(request);
});
electron.ipcMain.on('GIT_LOG', function (ev, cwd) {
gitLog(cwd, mainWin);
});
electron.ipcMain.on('NOTIFY', function (ev, notification) {
notifier.notify(__assign({}, notification, { message: notification.body }));
});
electron.ipcMain.on('SHOW_OR_FOCUS', function () {
showOrFocus(mainWin);
});
// HELPER FUNCTIONS
// ----------------
function createIndicator() {
indicatorMod.init({
app: app,
showApp: showApp,
quitApp: quitApp,
IS_MAC: IS_MAC,
IS_LINUX: IS_LINUX,
IS_GNOME: IS_GNOME,
ICONS_FOLDER: ICONS_FOLDER,
});
}
function createMainWin() {
mainWin = mainWinMod.createWindow({
app: app,
IS_DEV: IS_DEV,
ICONS_FOLDER: ICONS_FOLDER,
IS_MAC: IS_MAC,
quitApp: quitApp,
nestedWinParams: nestedWinParams,
indicatorMod: indicatorMod,
});
googleAuth.init();
}
function registerShowAppShortCut(shortcutPassed) {
if (shortcutPassed) {
// unregister all previous
electron.globalShortcut.unregisterAll();
// Register a shortcut listener.
var ret = electron.globalShortcut.register(shortcutPassed, function () {
if (mainWin.isFocused()) {
mainWin.hide();
}
else {
showOrFocus(mainWin);
}
});
if (!ret) {
errorHandler('Key registration failed: ' + shortcutPassed, shortcutPassed);
}
}
}
function showApp() {
showOrFocus(mainWin);
}
function quitApp() {
mainWin.webContents.send('ON_BEFORE_QUIT');
}
function quitAppNow() {
app.isQuiting = true;
app.quit();
}
function showOrFocus(passedWin) {
// default to main win
var win = passedWin || mainWin;
// sometimes when starting a second instance we get here although we don't want to
if (!win) {
log.info('special case occurred when showOrFocus is called even though, this is a second instance of the app');
return;
}
if (win.isVisible()) {
win.focus();
}
else {
win.show();
}
// focus window afterwards always
setTimeout(function () {
win.focus();
}, 60);
}
function idleChecker() {
getIdleTime(function (idleTime) {
if (idleTime === 'NO_SUPPORT' && idleInterval) {
clearInterval(idleInterval);
}
// sometimes when starting a second instance we get here although we don't want to
if (!mainWin) {
log.info('special case occurred when trackTimeFn is called even though, this is a second instance of the app');
return;
}
// don't update if the user is about to close
if (!app.isQuiting) {
mainWin.webContents.send('IDLE_TIME', idleTime);
}
});
}
function exec(ev, command) {
console.log('running command ' + command);
var exec = require('child_process').exec;
exec(command, function (error) {
if (error) {
errorHandler(error);
}
});
}
//# sourceMappingURL=main.js.map

View file

@ -180,10 +180,13 @@ function registerShowAppShortCut(shortcutPassed) {
showOrFocus(mainWin);
}
});
console.log(ret);
if (!ret) {
errorHandler('Key registration failed: ' + shortcutPassed, shortcutPassed);
}
// TODO make this work again
// tslint:disable-next-line
// if (!ret) {
// errorHandler('Key registration failed: ' + shortcutPassed, shortcutPassed);
// }
}
}
@ -196,7 +199,8 @@ function quitApp() {
}
function quitAppNow() {
app.isQuiting = true;
// tslint:disable-next-line
// app.isQuiting = true;
app.quit();
}
@ -235,9 +239,10 @@ function idleChecker() {
}
// don't update if the user is about to close
if (!app.isQuiting) {
mainWin.webContents.send('IDLE_TIME', idleTime);
}
// tslint:disable-next-line
// if (!app.isQuiting) {
// mainWin.webContents.send('IDLE_TIME', idleTime);
// }
});
}

View file

@ -19,7 +19,7 @@
],
"scripts": {
"ng": "ng",
"start": "NODE_ENV=DEV ./node_modules/.bin/electron ./electron/main.js",
"start": "NODE_ENV=DEV npm run electron:serve",
"startFrontend": "ng serve",
"buildFrontend": "ng build",
"buildFrontendElectron": "ng build --base-href .",