refactor tests for readability + linting fixes
This commit is contained in:
parent
9bbabc5038
commit
57fce6d6cc
12 changed files with 123 additions and 318 deletions
49
src/background/init.ts
Normal file
49
src/background/init.ts
Normal 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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue