index.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import "source-map-support/register";
  2. import { app, dialog } from "electron";
  3. import { init as initSocket, socket } from "./managers/socketManager";
  4. import { update as initAutoLaunch } from "./managers/launchManager";
  5. import { TrayManager } from "./managers/trayManager";
  6. import { checkForUpdate } from "./util/updateChecker";
  7. export let trayManager: TrayManager;
  8. //* When app is ready
  9. export let updateCheckerInterval = null;
  10. app.whenReady().then(async () => {
  11. trayManager = new TrayManager();
  12. await initAutoLaunch();
  13. await initSocket();
  14. if (app.isPackaged && app.name.includes("Portable")) {
  15. await checkForUpdate(true);
  16. updateCheckerInterval = setInterval(() => {
  17. checkForUpdate(true);
  18. }, 15 * 1000 * 60);
  19. }
  20. });
  21. //* If second instance started, close old one
  22. app.on("second-instance", () => app.exit(0));
  23. //* Send errors from app to extension
  24. process.on("unhandledRejection", rejection => {
  25. console.error(rejection);
  26. if (socket && socket.connected) socket.emit("unhandledRejection", rejection);
  27. });
  28. // TODO Find better way to log
  29. process.on("uncaughtException", err => {
  30. dialog.showErrorBox(err.name, err.stack);
  31. app.exit(0);
  32. });