mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat: enable strict mode for electron as well
This commit is contained in:
parent
c93da56575
commit
d24b6f231d
18 changed files with 266 additions and 313 deletions
|
|
@ -1,72 +0,0 @@
|
|||
import {App, BrowserWindow, dialog, ipcMain, MessageBoxReturnValue} from 'electron';
|
||||
import {getSettings} from './get-settings';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import {HANDLED_ERROR_PROP_STR} from '../src/app/app.constants';
|
||||
|
||||
// TODO this is ugly as f+ck
|
||||
export const appCloseHandler = (
|
||||
app: App,
|
||||
mainWin: BrowserWindow,
|
||||
) => {
|
||||
let isMainWinError = false;
|
||||
let ids = [];
|
||||
|
||||
const _quitApp = () => {
|
||||
(app as any).isQuiting = true;
|
||||
app.quit();
|
||||
};
|
||||
|
||||
ipcMain.on(IPC.APP_READY, () => isMainWinError = false);
|
||||
ipcMain.on(IPC.ERROR, (ev, error) => {
|
||||
if (!error || !error[HANDLED_ERROR_PROP_STR]) {
|
||||
isMainWinError = true;
|
||||
ids = [];
|
||||
}
|
||||
});
|
||||
ipcMain.on(IPC.REGISTER_BEFORE_CLOSE, (ev, {id}) => {
|
||||
ids.push(id);
|
||||
});
|
||||
ipcMain.on(IPC.UNREGISTER_BEFORE_CLOSE, (ev, {id}) => {
|
||||
ids.filter(idIn => idIn !== id);
|
||||
});
|
||||
ipcMain.on(IPC.BEFORE_CLOSE_DONE, (ev, {id}) => {
|
||||
ids.filter(idIn => idIn !== id);
|
||||
if (ids.length === 0) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mainWin.on('close', (event) => {
|
||||
if ((app as any).isQuiting) {
|
||||
app.quit();
|
||||
} else {
|
||||
event.preventDefault();
|
||||
if (ids.length > 0) {
|
||||
mainWin.webContents.send(IPC.NOTIFY_ON_CLOSE);
|
||||
} else {
|
||||
getSettings(mainWin, (appCfg) => {
|
||||
if (appCfg && appCfg.misc.isConfirmBeforeExit && !(app as any).isQuiting) {
|
||||
dialog.showMessageBox(mainWin,
|
||||
{
|
||||
type: 'question',
|
||||
buttons: ['Yes', 'No'],
|
||||
title: 'Confirm',
|
||||
message: 'Are you sure you want to quit?'
|
||||
}).then((choice: MessageBoxReturnValue) => {
|
||||
if (choice.response === 1) {
|
||||
return;
|
||||
} else if (choice.response === 0) {
|
||||
_quitApp();
|
||||
return;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_quitApp();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
@ -1,10 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg version="1.1" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"
|
||||
<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="#0b77d2" stroke="#0b77d2" 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="#fff" fill-rule="evenodd"/>
|
||||
</g>
|
||||
<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="#0b77d2"
|
||||
stroke="#0b77d2"
|
||||
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="#fff"
|
||||
fill-rule="evenodd" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 629 B |
|
|
@ -2,61 +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: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>
|
||||
height="64"
|
||||
id="svg3360"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="ico-white.svg"
|
||||
version="1.1"
|
||||
viewBox="0 0 64 64"
|
||||
width="64"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd">
|
||||
<defs
|
||||
id="defs3362" />
|
||||
<sodipodi:namedview
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
id="base"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:cx="82.291165"
|
||||
inkscape:cy="47.350794"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-height="1056"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-width="1869"
|
||||
inkscape:window-x="51"
|
||||
inkscape:window-y="24"
|
||||
inkscape:zoom="3.8890873"
|
||||
pagecolor="#ffffff"
|
||||
showgrid="true" />
|
||||
<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:groupmode="layer"
|
||||
inkscape:label="Layer 1">
|
||||
<path
|
||||
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
|
||||
id="path3395"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
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" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.9 KiB |
|
|
@ -2,61 +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: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>
|
||||
height="64"
|
||||
id="svg3360"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="ico.svg"
|
||||
version="1.1"
|
||||
viewBox="0 0 64 64"
|
||||
width="64"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd">
|
||||
<defs
|
||||
id="defs3362" />
|
||||
<sodipodi:namedview
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
id="base"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:cx="69.479799"
|
||||
inkscape:cy="75.977339"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-height="1056"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:window-width="1869"
|
||||
inkscape:window-x="51"
|
||||
inkscape:window-y="24"
|
||||
inkscape:zoom="5.5"
|
||||
pagecolor="#ffffff"
|
||||
showgrid="true" />
|
||||
<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:groupmode="layer"
|
||||
inkscape:label="Layer 1">
|
||||
<path
|
||||
d="M 0.65537046,34.582787 32.452267,63.855301 63.791548,0.94356422 30.222644,47.722023 Z"
|
||||
id="path3395"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc"
|
||||
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" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.9 KiB |
|
|
@ -4,7 +4,6 @@ import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|||
export const BACKUP_DIR = `${app.getPath('userData')}/backups`;
|
||||
console.log('Saving backups to', BACKUP_DIR);
|
||||
|
||||
|
||||
export function backupData(ev, data) {
|
||||
if (!existsSync(BACKUP_DIR)) {
|
||||
mkdirSync(BACKUP_DIR);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
import {IPC} from './ipc-events.const';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
const errorHandler = require('./error-handler');
|
||||
const mainWinMod = require('./main-window');
|
||||
|
|
@ -46,12 +46,11 @@ function init(params) {
|
|||
if (retCode === 1) {
|
||||
console.log(`Successfully requested service name '${serviceName}'!`);
|
||||
proceed();
|
||||
}
|
||||
/* Other return codes means various errors, check here
|
||||
(https://dbus.freedesktop.org/doc/api/html/group__DBusShared.html#ga37a9bc7c6eb11d212bf8d5e5ff3b50f9) for more
|
||||
information
|
||||
*/
|
||||
else {
|
||||
/* Other return codes means various errors, check here
|
||||
(https://dbus.freedesktop.org/doc/api/html/group__DBusShared.html#ga37a9bc7c6eb11d212bf8d5e5ff3b50f9) for more
|
||||
information
|
||||
*/
|
||||
} else {
|
||||
isDBusError = true;
|
||||
errorHandler(`DBus: Failed to request service name '${serviceName}'.Check what return code '${retCode}' means.`);
|
||||
}
|
||||
|
|
@ -86,28 +85,28 @@ function init(params) {
|
|||
|
||||
// Then we need to create the interface implementation (with actual functions)
|
||||
iface = {
|
||||
markAsDone: function () {
|
||||
markAsDone: () => {
|
||||
checkMainWin();
|
||||
const mainWin = mainWinMod.getWin();
|
||||
mainWin.webContents.send(IPC.TASK_MARK_AS_DONE);
|
||||
},
|
||||
startTask: function () {
|
||||
startTask: () => {
|
||||
checkMainWin();
|
||||
const mainWin = mainWinMod.getWin();
|
||||
mainWin.webContents.send(IPC.TASK_START);
|
||||
},
|
||||
pauseTask: function () {
|
||||
pauseTask: () => {
|
||||
checkMainWin();
|
||||
const mainWin = mainWinMod.getWin();
|
||||
mainWin.webContents.send(IPC.TASK_PAUSE);
|
||||
},
|
||||
showApp: function () {
|
||||
showApp: () => {
|
||||
params.showApp();
|
||||
},
|
||||
quitApp: function () {
|
||||
quitApp: () => {
|
||||
params.quitApp();
|
||||
},
|
||||
emit: function () {
|
||||
emit: () => {
|
||||
// no nothing, as usual
|
||||
}
|
||||
};
|
||||
|
|
@ -124,7 +123,7 @@ let isErrorShownOnce = false;
|
|||
|
||||
if (!isDBusError) {
|
||||
module.exports = {
|
||||
init: init,
|
||||
init,
|
||||
setTask: (taskId, taskText) => {
|
||||
// fail silently to prevent hundreds of error messages
|
||||
if (isDBusError || isErrorShownOnce) {
|
||||
|
|
|
|||
|
|
@ -57,19 +57,19 @@ function inspectElements() {
|
|||
}
|
||||
}
|
||||
|
||||
const addExtensionIfInstalled = (name, getPath) => {
|
||||
const isExtensionInstalled = nameIN => {
|
||||
return BrowserWindow.getDevToolsExtensions &&
|
||||
{}.hasOwnProperty.call(BrowserWindow.getDevToolsExtensions(), nameIN);
|
||||
};
|
||||
|
||||
try {
|
||||
if (!isExtensionInstalled(name)) {
|
||||
BrowserWindow.addDevToolsExtension(getPath(name));
|
||||
}
|
||||
} catch (_) {
|
||||
}
|
||||
};
|
||||
// const addExtensionIfInstalled = (name, getPath) => {
|
||||
// const isExtensionInstalled = nameIN => {
|
||||
// return BrowserWindow.getDevToolsExtensions &&
|
||||
// {}.hasOwnProperty.call(BrowserWindow.getDevToolsExtensions(), nameIN);
|
||||
// };
|
||||
//
|
||||
// try {
|
||||
// if (!isExtensionInstalled(name)) {
|
||||
// BrowserWindow.addDevToolsExtension(getPath(name));
|
||||
// }
|
||||
// } catch (_) {
|
||||
// }
|
||||
// };
|
||||
|
||||
export const initDebug = (opts, isAddReload) => {
|
||||
opts = Object.assign({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {getIsAppReady, getWin} from './main-window';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import {error} from 'electron-log';
|
||||
import { getIsAppReady, getWin } from './main-window';
|
||||
import { IPC } from './ipc-events.const';
|
||||
import { error } from 'electron-log';
|
||||
|
||||
const WAIT_FOR_WIN_TIMEOUT_DURATION = 4000;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {ipcMain} from 'electron';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import { ipcMain } from 'electron';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
let cb;
|
||||
export const getSettings = (win, cbIN) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {getWin} from './main-window';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import { getWin } from './main-window';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
export const getGitLog = (data) => {
|
||||
const exec = require('child_process').exec;
|
||||
|
|
@ -7,10 +7,10 @@ export const getGitLog = (data) => {
|
|||
|
||||
exec(cmd, {
|
||||
cwd: data.cwd
|
||||
}, function (error, stdout) {
|
||||
}, (error, stdout) => {
|
||||
const mainWin = getWin();
|
||||
mainWin.webContents.send(IPC.GIT_LOG_RESPONSE, {
|
||||
stdout: stdout,
|
||||
stdout,
|
||||
requestId: data.requestId
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {google} from 'googleapis';
|
||||
import {BrowserWindow, ipcMain, BrowserWindowConstructorOptions} from 'electron';
|
||||
import {getWin} from './main-window';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import { google } from 'googleapis';
|
||||
import { BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron';
|
||||
import { getWin } from './main-window';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
const A = {
|
||||
CLIENT_ID: '37646582031-e281jj291amtk805td0hgfqss2jfkdcd.apps.googleusercontent.com',
|
||||
|
|
@ -30,8 +30,6 @@ const BROWSER_WINDOW_PARAMS: BrowserWindowConstructorOptions = {
|
|||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new OAuth2 client with the configured keys.
|
||||
*/
|
||||
|
|
@ -41,7 +39,6 @@ const oauth2Client = new google.auth.OAuth2(
|
|||
'urn:ietf:wg:oauth:2.0:oob'
|
||||
);
|
||||
|
||||
|
||||
google.options({auth: oauth2Client});
|
||||
|
||||
async function authenticate(refreshToken) {
|
||||
|
|
@ -70,8 +67,11 @@ async function authenticate(refreshToken) {
|
|||
});
|
||||
oauth2Client.getAccessToken()
|
||||
.then((res) => {
|
||||
if (!res || !res.res) {
|
||||
reject(res);
|
||||
}
|
||||
// console.log('TOKEN REFRESH ', res.res.data);
|
||||
resolve(res.res.data);
|
||||
resolve((res.res as any).data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
|
@ -122,7 +122,6 @@ function openAuthWindow(url) {
|
|||
// console.log(tokens.access_token);
|
||||
// });
|
||||
|
||||
|
||||
export const initGoogleAuth = () => {
|
||||
ipcMain.on(IPC.TRIGGER_GOOGLE_AUTH, (ev, refreshToken) => {
|
||||
console.log('refreshToken', (refreshToken && refreshToken.length));
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {ipcMain, Menu, Tray} from 'electron';
|
||||
import {existsSync, readFileSync} from 'fs';
|
||||
import { App, ipcMain, Menu, Tray } from 'electron';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
// const dbus = require('./dbus');
|
||||
import {errorHandler} from './error-handler';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import { errorHandler } from './error-handler';
|
||||
import { IPC } from './ipc-events.const';
|
||||
|
||||
const GNOME_SHELL_EXT_MIN_VERSION = 2;
|
||||
|
||||
|
|
@ -10,14 +10,24 @@ let tray;
|
|||
let isIndicatorRunning = false;
|
||||
let isGnomeShellExtensionRunning = false;
|
||||
|
||||
export const initIndicator = (params) => {
|
||||
const IS_LINUX = params.IS_LINUX;
|
||||
const IS_GNOME = params.IS_GNOME;
|
||||
const showApp = params.showApp;
|
||||
const quitApp = params.quitApp;
|
||||
const IS_MAC = params.IS_MAC;
|
||||
const app = params.app;
|
||||
const ICONS_FOLDER = params.ICONS_FOLDER;
|
||||
export const initIndicator = ({
|
||||
IS_LINUX,
|
||||
IS_GNOME,
|
||||
IS_MAC,
|
||||
showApp,
|
||||
quitApp,
|
||||
app,
|
||||
ICONS_FOLDER,
|
||||
}: {
|
||||
IS_LINUX: boolean;
|
||||
IS_GNOME: boolean;
|
||||
IS_MAC: boolean;
|
||||
showApp: () => void;
|
||||
quitApp: () => void;
|
||||
app: App;
|
||||
ICONS_FOLDER: string;
|
||||
}) => {
|
||||
|
||||
const isGnomeShellExtensionInstalled = isGnomeShellInstalled(IS_LINUX, IS_GNOME);
|
||||
|
||||
initAppListeners(app);
|
||||
|
|
@ -95,7 +105,7 @@ function initAppListeners(app) {
|
|||
function initListeners(isGnomeShellExtInstalled) {
|
||||
ipcMain.on(IPC.CURRENT_TASK_UPDATED, (ev, params) => {
|
||||
const currentTask = params.current;
|
||||
const lastActiveTaskTask = params.lastActiveTask;
|
||||
// const lastActiveTaskTask = params.lastActiveTask;
|
||||
|
||||
let msg;
|
||||
|
||||
|
|
@ -126,9 +136,9 @@ function initListeners(isGnomeShellExtInstalled) {
|
|||
});
|
||||
|
||||
ipcMain.on(IPC.POMODORO_UPDATE, (ev, params) => {
|
||||
const isOnBreak = params.isOnBreak;
|
||||
const currentSessionTime = params.currentSessionTime;
|
||||
const currentSessionInitialTime = params.currentSessionInitialTime;
|
||||
// const isOnBreak = params.isOnBreak;
|
||||
// const currentSessionTime = params.currentSessionTime;
|
||||
// const currentSessionInitialTime = params.currentSessionInitialTime;
|
||||
|
||||
// if (isGnomeShellExtInstalled) {
|
||||
// dbus.updatePomodoro(isOnBreak, currentSessionTime, currentSessionInitialTime);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import {getWin} from './main-window';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import {session} from 'electron';
|
||||
import {JiraCfg} from '../src/app/features/issue/providers/jira/jira.model';
|
||||
import { getWin } from './main-window';
|
||||
import { IPC } from './ipc-events.const';
|
||||
import { session } from 'electron';
|
||||
import { JiraCfg } from '../src/app/features/issue/providers/jira/jira.model';
|
||||
// import rp from 'request-promise';
|
||||
// const rp = require('request-promise');
|
||||
import fetch from 'node-fetch';
|
||||
import {Agent} from 'https';
|
||||
import { Agent } from 'https';
|
||||
|
||||
export const sendJiraRequest = ({requestId, requestInit, url, jiraCfg}:
|
||||
{ requestId: string; requestInit: RequestInit; url: string, jiraCfg: JiraCfg }) => {
|
||||
{ requestId: string; requestInit: RequestInit; url: string, jiraCfg: JiraCfg }) => {
|
||||
const mainWin = getWin();
|
||||
// console.log('--------------------------------------------------------------------');
|
||||
// console.log(url);
|
||||
|
|
@ -51,7 +51,7 @@ export const sendJiraRequest = ({requestId, requestInit, url, jiraCfg}:
|
|||
|
||||
// TODO simplify and do encoding in frontend service
|
||||
export const setupRequestHeadersForImages = (jiraCfg: JiraCfg) => {
|
||||
const {host, protocol, port} = parseHostAndPort(jiraCfg);
|
||||
const {host, protocol} = parseHostAndPort(jiraCfg);
|
||||
|
||||
// TODO export to util fn
|
||||
const _b64EncodeUnicode = (str) => {
|
||||
|
|
@ -73,14 +73,18 @@ export const setupRequestHeadersForImages = (jiraCfg: JiraCfg) => {
|
|||
const MATCH_PROTOCOL_REG_EX = /(^[^:]+):\/\//;
|
||||
const MATCH_PORT_REG_EX = /:\d{2,4}/;
|
||||
|
||||
const parseHostAndPort = (config: JiraCfg) => {
|
||||
let host = config.host;
|
||||
const parseHostAndPort = (config: JiraCfg): { host: string, protocol: string, port: number } => {
|
||||
let host: string = config.host as string;
|
||||
let protocol;
|
||||
let port;
|
||||
|
||||
if (!host) {
|
||||
throw new Error('No host given');
|
||||
}
|
||||
|
||||
// parse port from host and remove it
|
||||
if (host.match(MATCH_PORT_REG_EX)) {
|
||||
const match = MATCH_PORT_REG_EX.exec(host);
|
||||
const match = MATCH_PORT_REG_EX.exec(host) as RegExpExecArray;
|
||||
host = host.replace(MATCH_PORT_REG_EX, '');
|
||||
port = parseInt(match[0].replace(':', ''), 10);
|
||||
}
|
||||
|
|
@ -93,7 +97,7 @@ const parseHostAndPort = (config: JiraCfg) => {
|
|||
// remove trailing slash just in case
|
||||
.replace(/\/$/, '');
|
||||
|
||||
protocol = match[1];
|
||||
protocol = (match as any)[1];
|
||||
} else {
|
||||
protocol = 'https';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {exec} from 'child_process';
|
||||
import { exec } from 'child_process';
|
||||
|
||||
export default (cb?, customCommands?) => {
|
||||
const lockCommands = customCommands || {
|
||||
|
|
|
|||
|
|
@ -9,21 +9,26 @@ import {
|
|||
MessageBoxReturnValue,
|
||||
shell
|
||||
} from 'electron';
|
||||
import {errorHandler} from './error-handler';
|
||||
import {join, normalize} from 'path';
|
||||
import {format} from 'url';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import {getSettings} from './get-settings';
|
||||
import { errorHandler } from './error-handler';
|
||||
import { join, normalize } from 'path';
|
||||
import { format } from 'url';
|
||||
import { IPC } from './ipc-events.const';
|
||||
import { getSettings } from './get-settings';
|
||||
|
||||
let mainWin: BrowserWindow;
|
||||
let indicatorMod;
|
||||
|
||||
const mainWinModule = {
|
||||
const mainWinModule: {
|
||||
win?: BrowserWindow;
|
||||
isAppReady: boolean;
|
||||
} = {
|
||||
win: undefined,
|
||||
isAppReady: false
|
||||
};
|
||||
|
||||
export const getWin = () => {
|
||||
export const getWin = (): BrowserWindow => {
|
||||
if (!mainWinModule.win) {
|
||||
throw new Error('No main window');
|
||||
}
|
||||
return mainWinModule.win;
|
||||
};
|
||||
|
||||
|
|
@ -31,20 +36,25 @@ export const getIsAppReady = () => {
|
|||
return mainWinModule.isAppReady;
|
||||
};
|
||||
|
||||
export const createWindow = (params) => {
|
||||
export const createWindow = ({
|
||||
IS_DEV,
|
||||
ICONS_FOLDER,
|
||||
IS_MAC,
|
||||
quitApp,
|
||||
app,
|
||||
}: {
|
||||
IS_DEV: boolean;
|
||||
ICONS_FOLDER: string;
|
||||
IS_MAC: boolean;
|
||||
quitApp: () => void;
|
||||
app: App;
|
||||
}): BrowserWindow => {
|
||||
// make sure the main window isn't already created
|
||||
if (mainWin) {
|
||||
errorHandler('Main window already exists');
|
||||
return;
|
||||
return mainWin;
|
||||
}
|
||||
|
||||
const IS_DEV = params.IS_DEV;
|
||||
const ICONS_FOLDER = params.ICONS_FOLDER;
|
||||
const IS_MAC = params.IS_MAC;
|
||||
const quitApp = params.quitApp;
|
||||
const app = params.app;
|
||||
indicatorMod = params.indicatorMod;
|
||||
|
||||
// workaround for https://github.com/electron/electron/issues/16521
|
||||
if (!IS_MAC) {
|
||||
Menu.setApplicationMenu(null);
|
||||
|
|
@ -159,12 +169,11 @@ function createMenu(quitApp) {
|
|||
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTplOUT));
|
||||
}
|
||||
|
||||
|
||||
// TODO this is ugly as f+ck
|
||||
const appCloseHandler = (
|
||||
app: App,
|
||||
) => {
|
||||
let ids = [];
|
||||
let ids: string[] = [];
|
||||
|
||||
const _quitApp = () => {
|
||||
(app as any).isQuiting = true;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
'use strict';
|
||||
import {App, app, globalShortcut, ipcMain, powerMonitor, BrowserWindow} from 'electron';
|
||||
import { App, app, BrowserWindow, globalShortcut, ipcMain, powerMonitor } from 'electron';
|
||||
import * as electronDl from 'electron-dl';
|
||||
|
||||
import {info} from 'electron-log';
|
||||
import {CONFIG} from './CONFIG';
|
||||
import { info } from 'electron-log';
|
||||
import { CONFIG } from './CONFIG';
|
||||
|
||||
import {initIndicator} from './indicator';
|
||||
import {createWindow} from './main-window';
|
||||
import { initIndicator } from './indicator';
|
||||
import { createWindow } from './main-window';
|
||||
|
||||
import {sendJiraRequest, setupRequestHeadersForImages} from './jira';
|
||||
import {getGitLog} from './git-log';
|
||||
import {initGoogleAuth} from './google-auth';
|
||||
import {errorHandler} from './error-handler';
|
||||
import {initDebug} from './debug';
|
||||
import {IPC} from './ipc-events.const';
|
||||
import {backupData} from './backup';
|
||||
import {JiraCfg} from '../src/app/features/issue/providers/jira/jira.model';
|
||||
import {KeyboardConfig} from '../src/app/features/config/global-config.model';
|
||||
import { sendJiraRequest, setupRequestHeadersForImages } from './jira';
|
||||
import { getGitLog } from './git-log';
|
||||
import { initGoogleAuth } from './google-auth';
|
||||
import { errorHandler } from './error-handler';
|
||||
import { initDebug } from './debug';
|
||||
import { IPC } from './ipc-events.const';
|
||||
import { backupData } from './backup';
|
||||
import { JiraCfg } from '../src/app/features/issue/providers/jira/jira.model';
|
||||
import { KeyboardConfig } from '../src/app/features/config/global-config.model';
|
||||
import lockscreen from './lockscreen';
|
||||
|
||||
const ICONS_FOLDER = __dirname + '/assets/icons/';
|
||||
|
|
@ -140,7 +140,6 @@ appIN.on('ready', () => {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
appIN.on('will-quit', () => {
|
||||
// un-register all shortcuts.
|
||||
globalShortcut.unregisterAll();
|
||||
|
|
@ -193,7 +192,6 @@ ipcMain.on(IPC.SET_PROGRESS_BAR, (ev, {progress, mode}) => {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
ipcMain.on(IPC.REGISTER_GLOBAL_SHORTCUTS_EVENT, (ev, cfg) => {
|
||||
registerShowAppShortCuts(cfg);
|
||||
});
|
||||
|
|
@ -235,8 +233,6 @@ function createMainWin() {
|
|||
ICONS_FOLDER,
|
||||
IS_MAC,
|
||||
quitApp,
|
||||
// TODO fix
|
||||
// indicatorMod,
|
||||
});
|
||||
initGoogleAuth();
|
||||
}
|
||||
|
|
@ -291,6 +287,9 @@ function registerShowAppShortCuts(cfg: KeyboardConfig) {
|
|||
mainWin.webContents.send(IPC.ADD_TASK);
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
actionFn = () => undefined;
|
||||
}
|
||||
|
||||
if (shortcut && shortcut.length > 0) {
|
||||
|
|
@ -349,7 +348,6 @@ function exec(ev, command) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
// required for graceful closing
|
||||
// @see: https://github.com/electron/electron/issues/5708
|
||||
process.on('exit', () => {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,7 @@
|
|||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"types": [],
|
||||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"main.ts",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@
|
|||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"strictNullChecks": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": true,
|
||||
"strictPropertyInitialization": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es5",
|
||||
"resolveJsonModule": true,
|
||||
"typeRoots": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue