]> Repos - mime-chat/commitdiff
testing autoupdate v0.9.6
authorAndrew Gundersen <gundersena@xavier.edu>
Thu, 15 Apr 2021 23:55:06 +0000 (18:55 -0500)
committerAndrew Gundersen <gundersena@xavier.edu>
Thu, 15 Apr 2021 23:55:06 +0000 (18:55 -0500)
package.json
src/background.ts
src/background/init.ts

index 56a7cf86f68f8508a5dce61ac101ac6caa44ae3b..bfd57b4d20bb13424f86bd3cc32534d69e56b5f7 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "Crimata",
-  "version": "0.9.5",
+  "version": "0.9.6",
   "private": true,
   "description": "Cross-platform messenger application built with electron, vue3, and TS.",
   "author": {
index 1147f86ab4aeb51391dfe22b460bf344a08bb5f1..8fafb4f7b93866955b4b90252c59f609c61a88ab 100644 (file)
@@ -5,10 +5,8 @@
 
 "use strict";
 
-const { autoUpdater } = require('electron-updater')
-
 import { initApp } from './background/init';
-import { protocol, dialog } from "electron";
+import { protocol } from "electron";
 
 // Scheme must be registered before the app is ready
 protocol.registerSchemesAsPrivileged([
@@ -21,47 +19,7 @@ const isDev = require('electron-is-dev');
 // NOTE Program Begins Here
 (async () => {
 
-    autoUpdater.requestHeaders = { 'PRIVATE-TOKEN': 'seMF_apn237iUw8puG9a' }
-
-    const dialogConfig = {
-        type: 'info',
-        buttons: ['Restart', 'Later'],
-        title: 'Application Update',
-        message: 'A new version has been downloaded. Restart to update.'
-    }
-
-    autoUpdater.on('checking-for-update', () => {
-        console.log("Checking for update...")
-    })
-
-    autoUpdater.on('update-available', () => {
-        console.log("Update available.")
-    })
-
-    autoUpdater.on('download-progress', function (progress: any) {
-        console.log(`Downloading update: ${progress.percent}`)
-    })
-
-    autoUpdater.on('error', (err: any) => {
-        console.log(String(err))
-    })
-
-    autoUpdater.on('update-downloaded', () => {
-        console.log("Update downloaded.")
-        dialog.showMessageBox(dialogConfig).then((returnValue) => {
-            if (returnValue.response === 0) autoUpdater.quitAndInstall()
-        })
-    })
-
-    autoUpdater.checkForUpdatesAndNotify()
-
-    setInterval(() => {
-        autoUpdater.checkForUpdatesAndNotify()
-    }, 5000)
-
     console.log('Starting Crimata electron app.');
-    initApp(isDev);
+    await initApp(isDev);
 
 })();
-
-https://gitlab.com/crimata/electron-app/-/package_files/9495519/download
\ No newline at end of file
index 52e184a2e5923d9937ece7e5345301aa970ea36b..3c242036efa346f45813bc7f9de2d667997be70c 100644 (file)
@@ -1,12 +1,11 @@
 
 "use strict";
 
-import { app } from "electron";
+import { app, dialog } from "electron";
 import { createWindow } from './window';
 import { initSession } from './session';
 import { initAudioIO } from './audio';
 import { backgroundMitt } from '@/modules/emitter';
-const { autoUpdater } = require('electron-updater');
 
 let win: boolean;
 
@@ -15,6 +14,30 @@ backgroundMitt.on('window-active', (state: boolean) => {
     win = state;
 });
 
+// Auto updating.
+const { autoUpdater } = require('electron-updater')
+autoUpdater.requestHeaders = { 'PRIVATE-TOKEN': 'seMF_apn237iUw8puG9a' }
+
+autoUpdater.on('update-available', (info: any) => {
+    console.log(`Update available: ${info.version}`)
+})
+
+autoUpdater.on('update-downloaded', (info: any) => {
+
+    const updateDialog = {
+        type: 'info',
+        buttons: ['Restart', 'Later'],
+        title: 'Application Update',
+        message: info.version,
+        detail: 'A new version has been downloaded. Restart the application to apply the updates.'
+    }
+
+    dialog.showMessageBox(updateDialog).then((returnValue) => {
+        if (returnValue.response === 0) autoUpdater.quitAndInstall()
+    })
+
+})
+
 // Run when electron app is initialized.
 async function main() {
     console.log("MAIN:Initializing Electron App.")
@@ -35,7 +58,13 @@ export function initApp(dev: boolean): void {
 
     // On initial startup.
     app.on("ready", () => {
-      main()
+
+        // Check for updates every 2min.
+        setInterval(() => {
+            autoUpdater.checkForUpdates()
+        }, 5000) // 5s for development.
+
+        main()
     });
 
     // Must keep to ensure app doesn't quit on close.
@@ -49,16 +78,16 @@ export function initApp(dev: boolean): void {
     // When user clicks app icon (re-open)
     app.on("activate", () => {
 
-      if (!win) {
-        createWindow();
-      }
+        if (!win) {
+            createWindow();
+        }
 
     });
 
     // Exit cleanly on request from parent process in development mode.
     if (dev) {
         process.on("SIGTERM", () => {
-           app.quit();
+            app.quit();
         });
     }
 }