From 594f07d729d5017c16c8fff55e4327a27d7133aa Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 27 Jun 2023 20:31:02 -0400 Subject: [PATCH] add auto update check --- desktop/src/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/desktop/src/index.ts b/desktop/src/index.ts index 77e7b82a..26cd6784 100644 --- a/desktop/src/index.ts +++ b/desktop/src/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, autoUpdater } from 'electron' +import { app, BrowserWindow, autoUpdater, dialog } from 'electron' import { spawn } from 'child_process' import * as path from 'path' @@ -87,3 +87,17 @@ autoUpdater.setFeedURL({ url: `https://updates.ollama.ai/update/${process.platfo setInterval(() => { autoUpdater.checkForUpdates() }, 60000) + +autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { + dialog + .showMessageBox({ + type: 'info', + buttons: ['Restart Now', 'Later'], + title: 'New update available', + message: process.platform === 'win32' ? releaseNotes : releaseName, + detail: 'A new version of Ollama is available. Restart to apply the update.', + }) + .then(returnValue => { + if (returnValue.response === 0) autoUpdater.quitAndInstall() + }) +})