Skip to content

Commit 4c5785b

Browse files
committed
feat: linux electron auto update working
1 parent f16e121 commit 4c5785b

4 files changed

Lines changed: 380 additions & 9 deletions

File tree

src-node/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/document/DocumentCommandHandlers.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,10 +1731,18 @@ define(function (require, exports, module) {
17311731
.finally(()=>{
17321732
raceAgainstTime(_safeNodeTerminate())
17331733
.finally(()=>{
1734-
// In Electron, use allowClose() to bypass the close handler
1735-
// (which would otherwise trigger another cleanup cycle).
1734+
// In Electron multi-window case, use allowClose() to bypass
1735+
// the close handler (which would otherwise trigger another
1736+
// cleanup cycle). But for last window, closeWindow() calls
1737+
// quitApp() (no loop) and runs quitTimeAppUpdateHandler.
17361738
if(window.__ELECTRON__) {
1737-
window.electronAPI.allowClose();
1739+
Phoenix.app.getPhoenixInstanceCount().then(count => {
1740+
if(count === 1) {
1741+
Phoenix.app.closeWindow();
1742+
} else {
1743+
window.electronAPI.allowClose();
1744+
}
1745+
});
17381746
} else {
17391747
Phoenix.app.closeWindow();
17401748
}
@@ -2276,11 +2284,19 @@ define(function (require, exports, module) {
22762284
raceAgainstTime(_safeNodeTerminate())
22772285
.finally(()=>{
22782286
closeInProgress = false;
2279-
// In Electron, we must call allowClose() to complete the original
2280-
// close request (sets forceClose=true). Calling closeWindow() would
2287+
// In Electron multi-window case, we must call allowClose() to
2288+
// complete the original close request. Calling closeWindow() would
22812289
// trigger a new close sequence and cause an infinite loop.
2290+
// But for last window, closeWindow() calls quitApp() (no loop),
2291+
// and we need it to run quitTimeAppUpdateHandler.
22822292
if(window.__ELECTRON__) {
2283-
window.electronAPI.allowClose();
2293+
Phoenix.app.getPhoenixInstanceCount().then(count => {
2294+
if(count === 1) {
2295+
Phoenix.app.closeWindow();
2296+
} else {
2297+
window.electronAPI.allowClose();
2298+
}
2299+
});
22842300
} else {
22852301
Phoenix.app.closeWindow();
22862302
}

src/extensionsIntegrated/appUpdater/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// shell.js file. This is app updates are pretty core level even though we do it as an extension here.
2525

2626
define(function (require, exports, module) {
27+
require("./update-electron");
2728
const AppInit = require("utils/AppInit"),
2829
Metrics = require("utils/Metrics"),
2930
FileSystem = require("filesystem/FileSystem"),
@@ -521,7 +522,6 @@ define(function (require, exports, module) {
521522
// app updates are only for desktop builds
522523
return;
523524
}
524-
// todo electron edge for app updater
525525
if (brackets.platform === "mac") {
526526
// in mac, the `update.app.tar.gz` is downloaded, and only extracted on app quit.
527527
// we do this only in mac as the `.app` file is extracted only at app quit and deleted

0 commit comments

Comments
 (0)