feat(desktop 0.1.5): show version + Check for updates in Settings (#12)

- Settings now shows 'Biz Connect for Desktop · Version x.y.z' with a Check for
  updates button (desktop only, feature-detected).
- preload exposes checkForUpdates(); main.js adds the check-updates IPC (returns
  available/current/dev/error) and, when a build finishes downloading, shows a
  Restart now / Later dialog instead of only the silent on-next-launch install.
- desktop version bumped 0.1.4 -> 0.1.5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-07 16:12:21 +05:30
parent a9b3533f7a
commit ff436704ec
4 changed files with 46 additions and 2 deletions
+26
View File
@@ -35,6 +35,17 @@ ipcMain.on('get-install-info', (e) => {
// on the next restart. No-op in dev (unpackaged).
let autoUpdater = null;
try { ({ autoUpdater } = require('electron-updater')); } catch (_) { /* not installed in dev */ }
// #12: manual "Check for updates" from Settings. Returns the current status; the background updater
// (configured in app.whenReady) downloads and prompts to restart when a build is ready.
ipcMain.handle('check-updates', async () => {
const current = app.getVersion();
if (!app.isPackaged || !autoUpdater) return { status: 'dev', current };
try {
const r = await autoUpdater.checkForUpdates();
const v = r && r.updateInfo && r.updateInfo.version;
return (v && v !== current) ? { status: 'available', version: v, current } : { status: 'current', current };
} catch (e) { return { status: 'error', message: String((e && e.message) || e), current }; }
});
// Chat toast: sender/group avatar + message; clicking it raises the app and opens that chat.
// Uses Electron's OWN Notification (native, no SnoreToast) whose 'click' event fires reliably.
const APP_ID = 'com.bizgaze.connect.desktop';
@@ -205,6 +216,21 @@ app.whenReady().then(() => {
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });
// Check for shell updates on launch, then every 6 hours. Only in packaged builds.
if (app.isPackaged && autoUpdater) {
// When an update finishes downloading (auto or via the Settings "Check for updates"), offer a
// clear restart prompt instead of only the silent on-next-launch install.
let promptedForUpdate = false;
autoUpdater.on('update-downloaded', async (info) => {
if (promptedForUpdate) return; promptedForUpdate = true;
try {
const { dialog } = require('electron');
const res = await dialog.showMessageBox(win || undefined, {
type: 'info', buttons: ['Restart now', 'Later'], defaultId: 0, cancelId: 1,
title: 'Update ready', message: 'Biz Connect ' + ((info && info.version) || '') + ' is ready.',
detail: 'Restart the app to finish updating.',
});
if (res.response === 0) autoUpdater.quitAndInstall();
} catch (_) { /* fall back to install-on-next-launch */ }
});
const check = () => autoUpdater.checkForUpdatesAndNotify().catch(() => {});
check();
setInterval(check, 6 * 60 * 60 * 1000);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "biz-connect-desktop",
"version": "0.1.4",
"version": "0.1.5",
"description": "Biz Connect technician desktop client — loads the Connect web UI with native screen capture",
"author": {
"name": "BizGaze",
+3
View File
@@ -22,4 +22,7 @@ contextBridge.exposeInMainWorld('bizConnectNative', Object.freeze({
// Native Windows toast with an inline reply box. Resolves to {text} (replied), {open} (clicked)
// or null. Lets the user reply to a chat straight from the notification.
replyNotify: (payload) => ipcRenderer.invoke('reply-notification', payload),
// Manual "Check for updates" from Settings. Resolves {status:'available'|'current'|'dev'|'error', version?}.
// On 'available' the shell downloads in the background and prompts to restart when ready.
checkForUpdates: () => ipcRenderer.invoke('check-updates'),
}));