mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-22 06:54:44 +00:00
remove listeners on quitAndInstall to try fix macOS update issue
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
"use strict";
|
||||
const electron_updater_1 = require("electron-updater");
|
||||
const electron_1 = require("electron");
|
||||
let electronSocket;
|
||||
module.exports = (socket) => {
|
||||
module.exports = (socket, app) => {
|
||||
electronSocket = socket;
|
||||
socket.on('register-autoUpdater-error-event', (id) => {
|
||||
electron_updater_1.autoUpdater.on('error', (error) => {
|
||||
@@ -100,6 +101,20 @@ module.exports = (socket) => {
|
||||
});
|
||||
});
|
||||
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
|
||||
app.removeAllListeners("window-all-closed");
|
||||
const windows = electron_1.BrowserWindow.getAllWindows();
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
w.removeAllListeners('close');
|
||||
w.hide();
|
||||
w.destroy();
|
||||
}
|
||||
catch {
|
||||
//ignore, probably already destroyed
|
||||
}
|
||||
});
|
||||
}
|
||||
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||
});
|
||||
socket.on('autoUpdaterDownloadUpdate', async (guid) => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Socket } from 'net';
|
||||
import { BrowserWindow } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
let electronSocket;
|
||||
|
||||
export = (socket: Socket) => {
|
||||
export = (socket: Socket, app: Electron.App) => {
|
||||
electronSocket = socket;
|
||||
|
||||
socket.on('register-autoUpdater-error-event', (id) => {
|
||||
@@ -128,6 +129,20 @@ export = (socket: Socket) => {
|
||||
});
|
||||
|
||||
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
|
||||
app.removeAllListeners("window-all-closed");
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
w.removeAllListeners('close');
|
||||
w.hide();
|
||||
w.destroy();
|
||||
}
|
||||
catch {
|
||||
//ignore, probably already destroyed
|
||||
}
|
||||
});
|
||||
}
|
||||
autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
|
||||
});
|
||||
|
||||
|
||||
@@ -269,6 +269,7 @@ module.exports = (socket, app) => {
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
w.removeAllListeners('close');
|
||||
w.hide();
|
||||
w.destroy();
|
||||
count++;
|
||||
|
||||
@@ -58,6 +58,7 @@ app.on('before-quit-for-update', () => {
|
||||
app.removeAllListeners("window-all-closed");
|
||||
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
@@ -263,12 +264,12 @@ function startSocketApiBridge(port) {
|
||||
global['electronsocket'].setMaxListeners(0);
|
||||
}
|
||||
|
||||
console.log('ASP.NET Core Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
|
||||
console.log('.NET Application connected...', 'global.electronsocket', global['electronsocket'].id, new Date());
|
||||
|
||||
if (appApi === undefined) appApi = require('./api/app')(socket, app);
|
||||
if (browserWindows === undefined) browserWindows = require('./api/browserWindows')(socket, app);
|
||||
if (commandLine === undefined) commandLine = require('./api/commandLine')(socket, app);
|
||||
if (autoUpdater === undefined) autoUpdater = require('./api/autoUpdater')(socket);
|
||||
if (autoUpdater === undefined) autoUpdater = require('./api/autoUpdater')(socket, app);
|
||||
if (ipc === undefined) ipc = require('./api/ipc')(socket);
|
||||
if (menu === undefined) menu = require('./api/menu')(socket);
|
||||
if (dialogApi === undefined) dialogApi = require('./api/dialog')(socket);
|
||||
@@ -360,7 +361,7 @@ function startAspCoreBackend(electronPort) {
|
||||
}
|
||||
|
||||
function startBackend(aspCoreBackendPort) {
|
||||
console.log('ASP.NET Core Port: ' + aspCoreBackendPort);
|
||||
console.log('.NET Core Port: ' + aspCoreBackendPort);
|
||||
loadURL = `http://localhost:${aspCoreBackendPort}`;
|
||||
const parameters = [getEnvironmentParameter(), `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`, `/electronPID=${process.pid}`];
|
||||
let binaryFile = manifestJsonFile.executable;
|
||||
@@ -397,7 +398,7 @@ function startAspCoreBackend(electronPort) {
|
||||
}
|
||||
|
||||
apiProcess.on('close', (code) => {
|
||||
console.log(`ASP.NET Process exited with code ${code}`);
|
||||
console.log(`.NET process exited with code ${code}`);
|
||||
if (code != 0 && !ignoreApiProcessClosed) {
|
||||
console.log(`Will quit Electron, as exit code != 0 (got ${code})`);
|
||||
app.exit(code);
|
||||
@@ -405,7 +406,7 @@ function startAspCoreBackend(electronPort) {
|
||||
});
|
||||
|
||||
if (detachedProcess) {
|
||||
console.log('Detached from ASP.NET process');
|
||||
console.log('Detached from .NET process');
|
||||
apiProcess.unref();
|
||||
}
|
||||
}
|
||||
@@ -422,7 +423,7 @@ function startAspCoreBackendWithWatch(electronPort) {
|
||||
}
|
||||
|
||||
function startBackend(aspCoreBackendPort) {
|
||||
console.log('ASP.NET Core Watch Port: ' + aspCoreBackendPort);
|
||||
console.log('.NET watch Port: ' + aspCoreBackendPort);
|
||||
loadURL = `http://localhost:${aspCoreBackendPort}`;
|
||||
const parameters = ['watch', 'run', getEnvironmentParameter(), `/electronPort=${electronPort}`, `/electronWebPort=${aspCoreBackendPort}`, `/electronPID=${process.pid}`];
|
||||
|
||||
@@ -451,7 +452,7 @@ function startAspCoreBackendWithWatch(electronPort) {
|
||||
}
|
||||
|
||||
apiProcess.on('close', (code) => {
|
||||
console.log(`ASP.NET Process exited with code ${code}`);
|
||||
console.log(`.NET process exited with code ${code}`);
|
||||
if (code != 0 && !ignoreApiProcessClosed) {
|
||||
console.log(`Will quit Electron, as exit code != 0 (got ${code})`);
|
||||
app.exit(code);
|
||||
|
||||
Reference in New Issue
Block a user