]> Repos - mime-chat/commitdiff
merged origin/main into main
authorAndrew Gundersen <gundersena@xavier.edu>
Fri, 5 Feb 2021 19:21:53 +0000 (13:21 -0600)
committerAndrew Gundersen <gundersena@xavier.edu>
Fri, 5 Feb 2021 19:21:53 +0000 (13:21 -0600)
1  2 
src/background.ts
src/background/initApp.ts

index cf052e0f3dcc3d20965007c8a709e2e892841801,5b5ceec0a6cc41eb7591148bfc586e2a1cbf6191..0b11170822a89fca0174e1434ad52955e1be788e
@@@ -1,27 -1,25 +1,24 @@@
+ /*
+  * Entry point for Crimata electron app.
+  * "Look on my Works, ye Mighty, and despair!"
+  */
  "use strict";
- import {initApp} from './background/initApp';
- import {Recorder} from './background/recorder';
- const portAudio = require('naudiodon');
 -
+ import { protocol } from "electron";
+ import { initApp } from './background/initApp';
+ // Scheme must be registered before the app is ready
+ protocol.registerSchemesAsPrivileged([
+     { scheme: "app", privileges: { secure: true, standard: true } }
+ ]);
  
+ // Load environment variable
+ const isDevelopment = process.env.NODE_ENV !== "production";
  
  // NOTE Program Begins Here
  (async () => {
  
-     const isDevelopment = process.env.NODE_ENV !== "production";
-     const recorder = new Recorder({
-         channelCount: 1,
-         sampleFormat: portAudio.SampleFormat16Bit,
-         sampleRate: 16000,
-         deviceId: -1, // Use -1 or omit the deviceId to select the default device
-         closeOnError: true
-     }, 'binary');
-     try {
-         // await authenticate method
-         initApp(isDevelopment);
-     } catch (e) {
-         console.log("Error", e);
-     }
+     console.log('Starting Crimata electron app.');
+     initApp(isDevelopment);
  
 -})();
 +})();
index 4006055e20cd5b270355ddf6d8139ff77c49e873,40de858cf3ef02c65a6dec2a67bdfed462f39fef..6fb9ac301be78ec1e719ee86104f23e7923694c0
@@@ -1,73 -1,20 +1,19 @@@
 -
  "use strict";
  
- import { app, protocol, BrowserWindow } from "electron";
- import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
- import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
- import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
- import * as path from "path";
+ import { app } from "electron";
+ import { main } from './run';
+ import { windowEmitter } from './windowEmitter';
  
- let win: BrowserWindow | null;
+ export function initApp(dev: boolean): void {
  
- function createWindow() {
-   // Create the browser window.
-   win = new BrowserWindow({
-     width: 350,
-     height: 500,
-     resizable: true,
+     let winActive: boolean;
  
-     x: 10,
-     y: 10,
-     webPreferences: {
-       devTools: false,
-       // Use pluginOptions.nodeIntegration, leave this alone
-       // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
-       nodeIntegration: (process.env
-         .ELECTRON_NODE_INTEGRATION as unknown) as boolean,
-       preload: path.join(__dirname, "preload.js")
-     }
-   });
-   if (process.env.WEBPACK_DEV_SERVER_URL) {
-     // Load the url of the dev server if in development mode
-     win.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string);
-     // NOTE uncomment for dev tools on app launch
-     if (!process.env.IS_TEST) win.webContents.openDevTools();
-   } else {
-     createProtocol("app");
-     // Load the index.html when not in development
-     win.loadURL("app://./index.html");
-   }
-   win.webContents.on('did-finish-load', () => {
-       // do stuff once window has finished loading
-   })
-   win.on("closed", () => {
-     win = null;
-   });
- }
- export function initApp(isDev: boolean){
-     // Scheme must be registered before the app is ready
-     protocol.registerSchemesAsPrivileged([
-       { scheme: "app", privileges: { secure: true, standard: true } }
-     ]);
+     windowEmitter.on('window-active', (state: boolean) => {
+         winActive =  state;
+     });
  
-     // This method will be called when Electron has finished
-     // initialization and is ready to create browser windows.
-     // Some APIs can only be used after this event occurs.
-     app.on("ready", async () => {
-       if (isDev && !process.env.IS_TEST) {
-         // Install Vue Devtools
-         try {
-           await installExtension(VUEJS_DEVTOOLS);
-         } catch (e) {
-           console.error("Vue Devtools failed to install:", e.toString());
-         }
-       }
-       createWindow();
+     app.on("ready", () => {
+       main();
      });
  
      // Quit when all windows are closed.