49 lines
1 KiB
TypeScript
49 lines
1 KiB
TypeScript
"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();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|