Ver Fonte

3.20.11

cocktailpeanut há 1 mês atrás
pai
commit
5968dbd0cc
4 ficheiros alterados com 26 adições e 6 exclusões
  1. 1 1
      full.js
  2. 4 1
      minimal.js
  3. 2 2
      package.json
  4. 19 2
      updater.js

+ 1 - 1
full.js

@@ -581,7 +581,6 @@ document.querySelector("form").addEventListener("submit", (e) => {
         }
       }
     })
-    updater.run()
     PORT = pinokiod.port
 
     theme = pinokiod.theme
@@ -652,6 +651,7 @@ document.querySelector("form").addEventListener("submit", (e) => {
       }
     }
     createWindow(PORT)
+    updater.run(mainWindow)
   })
 
 }

+ 4 - 1
minimal.js

@@ -6,6 +6,7 @@ const Updater = require('./updater')
 const pinokiod = new Pinokiod(config)
 const updater = new Updater()
 let tray
+let hiddenWindow
 app.whenReady().then(async () => {
   await pinokiod.start({
     onquit: () => {
@@ -23,7 +24,6 @@ app.whenReady().then(async () => {
       }
     }
   })
-  updater.run()
   if (process.platform === 'darwin') app.dock.hide();
   let icon = nativeImage.createFromPath(path.resolve(process.resourcesPath, "assets/icon_small.png"))
   icon = icon.resize({
@@ -43,4 +43,7 @@ app.whenReady().then(async () => {
     tray.popUpContextMenu(contextMenu);
   });
   shell.openExternal("http://localhost:42000");
+  hiddenWindow = new BrowserWindow({ show: false });
+
+  updater.run(hiddenWindow)
 });

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
   "name": "Pinokio",
   "private": true,
-  "version": "3.20.10",
+  "version": "3.20.11",
   "homepage": "https://pinokio.co",
   "description": "pinokio",
   "main": "main.js",
@@ -128,7 +128,7 @@
     "electron-store": "^8.1.0",
     "electron-updater": "^6.6.2",
     "electron-window-state": "^5.0.3",
-    "pinokiod": "^3.20.10"
+    "pinokiod": "^3.20.11"
   },
   "devDependencies": {
     "@electron/rebuild": "3.2.10",

+ 19 - 2
updater.js

@@ -2,7 +2,9 @@ const { autoUpdater } = require("electron-updater");
 const { dialog } = require('electron')
 
 class Updater {
-  run() {
+  run(mainWindow) {
+    autoUpdater.autoDownload = false;
+
     // Called when checking for an update
     autoUpdater.on('checking-for-update', () => {
       console.log('Checking for update...');
@@ -11,6 +13,21 @@ class Updater {
     // Called when an update is available
     autoUpdater.on('update-available', (info) => {
       console.log('Update available:', info.version);
+
+      // Ask user if they want to download
+      dialog.showMessageBox(mainWindow, {
+        type: 'question',
+        buttons: ['Yes', 'No'],
+        defaultId: 0,
+        cancelId: 1,
+        title: 'Update Available',
+        message: `Version ${info.version} is available. Do you want to download it now?`
+      }).then(result => {
+        if (result.response === 0) {
+          autoUpdater.downloadUpdate();
+        }
+      });
+
     });
 
     // Called when no update is found
@@ -32,7 +49,7 @@ class Updater {
       dialog.showMessageBox(mainWindow, {
         type: 'info',
         buttons: ['Restart Now', 'Later'],
-        title: 'Update Available',
+        title: 'Update Ready',
         message: 'A new version has been downloaded. Restart the application to apply the updates?'
       }).then(result => {
         if (result.response === 0) { // Restart Now