refactor tests for readability + linting fixes

This commit is contained in:
Enrique Hernandez 2021-02-10 23:04:53 -06:00
commit 57fce6d6cc
12 changed files with 123 additions and 318 deletions

49
src/background/init.ts Normal file
View file

@ -0,0 +1,49 @@
"use strict";
import { app } from "electron";
import { main } from './run';
import { backgroundMitt } from './emitter';
let winActive: boolean;
backgroundMitt.on('window-active', (state: boolean) => {
winActive = state;
});
export function initApp(dev: boolean): void {
app.on("ready", () => {
main();
});
// Quit when all windows are closed.
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
// TODO: Debug activate functionaity: currently not working.
// Might have to de-reference window object
app.on("activate", () => {
if (winActive === false) {
main();
}
});
// Exit cleanly on request from parent process in development mode.
if (dev) {
if (process.platform === "win32") {
process.on("message", data => {
if (data === "graceful-exit") {
app.quit();
}
});
} else {
process.on("SIGTERM", () => {
app.quit();
});
}
}
}