fix: honor automatic updates preference and add Settings controls

This commit is contained in:
amosblomqvist
2026-10-25 19:19:38 +02:00
parent b277ee3e0f
commit 769fc85e17
14 changed files with 820 additions and 75 deletions
+27 -3
View File
@@ -19,14 +19,25 @@
*
* window.lh.onUpdateStatus(cb) / window.lh.installUpdate() — the
* auto-update channel (Wave C, 2026-10-10): "lh:update-status" pushes
* {status:"downloaded", version} once an update is staged; installUpdate
* asks main to kill the server and quit-and-install. Browser builds:
* both absent, the banner never renders.
* {status, version, revision} on updater events; installUpdate asks main
* to kill the server and quit-and-install. getUpdateState retrieves the
* snapshot for a late subscriber; checkForUpdates requests a manual
* check (including download/install-on-quit, even with automatic checks OFF).
*
* window.lh.onOpenSettings(cb) — menu navigation, buffered until React
* subscribes after a window is reopened. Browser builds have no bridge.
*
* Channel names are mirrored in electron/main.cjs — keep them in sync.
*/
const { contextBridge, ipcRenderer } = require("electron");
let openSettingsListener = null;
let pendingOpenSettings = null;
ipcRenderer.on("lh:open-settings", (_event, section) => {
if (openSettingsListener) openSettingsListener(section);
else pendingOpenSettings = section;
});
contextBridge.exposeInMainWorld("lh", {
platform: process.platform,
chatgpt: {
@@ -71,4 +82,17 @@ contextBridge.exposeInMainWorld("lh", {
return () => ipcRenderer.removeListener("lh:update-status", listener);
},
installUpdate: () => ipcRenderer.send("lh:update-install"),
getUpdateState: () => ipcRenderer.invoke("lh:update:get"),
checkForUpdates: () => ipcRenderer.invoke("lh:update:check"),
onOpenSettings: (cb) => {
openSettingsListener = cb;
if (pendingOpenSettings !== null) {
const section = pendingOpenSettings;
pendingOpenSettings = null;
cb(section);
}
return () => {
if (openSettingsListener === cb) openSettingsListener = null;
};
},
});