From 90a0dad0ec2a17c0840910d0cece4eaec83fde50 Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Wed, 25 Mar 2026 06:56:13 +1100 Subject: [PATCH] feat: add download and install update functionality in IPC --- cinny | 2 +- electron/main.js | 15 +++++++++++++++ electron/preload.js | 6 +----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cinny b/cinny index 9d744ff..05e5ac7 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit 9d744ff3cc32bce0ec2ec567489070f5fff074ea +Subproject commit 05e5ac71b757828ca114faa8fc11a74901d19a00 diff --git a/electron/main.js b/electron/main.js index 9b477df..2681c97 100644 --- a/electron/main.js +++ b/electron/main.js @@ -934,6 +934,21 @@ ipcMain.handle('install-update', () => { return { success: true }; }); +ipcMain.handle('download-and-install-update', async () => { + if (isDev) { + return { success: false, error: 'Updates are not available in development mode' }; + } + try { + const result = await downloadGiteaUpdate(); + if (!result.opened) { + installGiteaUpdate(); + } + return { success: true, data: result }; + } catch (error) { + return { success: false, error: error.message }; + } +}); + // Screen capture / desktopCapturer handler ipcMain.handle('get-desktop-sources', async (event, opts) => { try { diff --git a/electron/preload.js b/electron/preload.js index c48b000..8d44a14 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -127,17 +127,13 @@ contextBridge.exposeInMainWorld('electron', { // Auto-updater updater: { checkForUpdates: () => ipcRenderer.invoke('check-for-updates'), - downloadUpdate: () => ipcRenderer.invoke('download-update'), - installUpdate: () => ipcRenderer.invoke('install-update'), + downloadAndInstallUpdate: () => ipcRenderer.invoke('download-and-install-update'), onUpdateAvailable: (callback) => { ipcRenderer.on('update-available', (_, info) => callback(info)); }, onUpdateDownloadProgress: (callback) => { ipcRenderer.on('update-download-progress', (_, progress) => callback(progress)); }, - onUpdateDownloaded: (callback) => { - ipcRenderer.on('update-downloaded', (_, info) => callback(info)); - } }, // Desktop capturer (for screen sharing)