Skip to content

Commit f3da6be

Browse files
committed
chore: auto update working in linux
1 parent 0c32990 commit f3da6be

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/extensionsIntegrated/appUpdater/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,14 @@ define(function (require, exports, module) {
518518

519519
let updateInstalledDialogShown = false, updateFailedDialogShown = false;
520520
AppInit.appReady(function () {
521-
if(!window.__TAURI__ || Phoenix.isTestWindow) {
521+
if(Phoenix.isTestWindow) {
522+
return;
523+
}
524+
if(window.__ELECTRON__) {
525+
// Electron updates handled by update-electron.js
526+
return;
527+
}
528+
if(!window.__TAURI__) {
522529
// app updates are only for desktop builds
523530
return;
524531
}

src/extensionsIntegrated/appUpdater/update-electron.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ define(function (require, exports, module) {
178178
updateScheduled = true;
179179
updatePendingRestart = true;
180180
cachedUpdateDetails = updateDetails;
181+
// Store in shared state so other windows know update is scheduled
182+
await window.electronAPI.setUpdateScheduled(true);
181183
showOrHideUpdateIcon();
182184
Metrics.countEvent(Metrics.EVENT_TYPE.UPDATES, 'scheduled', Phoenix.platform);
183185
updateTask.setSucceded();
@@ -313,6 +315,8 @@ define(function (require, exports, module) {
313315
if(!updateScheduled){
314316
return;
315317
}
318+
// Clear the scheduled flag in shared state
319+
await window.electronAPI.setUpdateScheduled(false);
316320
console.log("Installing update at quit time");
317321
return new Promise(resolve => {
318322
let dialog;
@@ -442,7 +446,7 @@ define(function (require, exports, module) {
442446
});
443447
}
444448

445-
AppInit.appReady(function () {
449+
AppInit.appReady(async function () {
446450
if(!window.__ELECTRON__ || Phoenix.isTestWindow) {
447451
return;
448452
}
@@ -451,6 +455,29 @@ define(function (require, exports, module) {
451455
console.error("App updates not yet implemented on this platform in Electron builds!");
452456
return;
453457
}
458+
// Check if another window already scheduled an update (multi-window state persistence)
459+
// This ensures the quit handler is registered in this window too
460+
try {
461+
const isUpdateScheduled = await window.electronAPI.getUpdateScheduled();
462+
if (isUpdateScheduled) {
463+
updateScheduled = true;
464+
updatePendingRestart = true;
465+
// Create task in success state (update ready, waiting for restart)
466+
updateTask = TaskManager.addNewTask(Strings.UPDATE_DONE, Strings.UPDATE_RESTART_INSTALL,
467+
`<i class="fa-solid fa-cogs"></i>`, {
468+
noSpinnerNotification: true,
469+
onSelect: function () {
470+
Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE,
471+
Strings.UPDATE_READY_RESTART_INSTALL_MESSAGE);
472+
}
473+
});
474+
updateTask.setSucceded();
475+
Phoenix.app.registerQuitTimeAppUpdateHandler(quitTimeAppUpdateHandler);
476+
console.log("Update was scheduled in another window, registering quit handler");
477+
}
478+
} catch (e) {
479+
console.error("Error checking shared state for update state:", e);
480+
}
454481
$("#update-notification").click(()=>{
455482
checkForUpdates();
456483
});

0 commit comments

Comments
 (0)