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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user