From e751e47d701f6def220951c7b3662ac150270823 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Wed, 26 Jul 2023 14:04:36 -0400 Subject: [PATCH] app: remove dialog, icons for updates --- app/assets/iconTemplate.png | Bin 0 -> 447 bytes ...x16Template@2x.png => iconTemplate@2x.png} | Bin app/assets/iconUpdateTemplate.png | Bin 0 -> 443 bytes app/assets/iconUpdateTemplate@2x.png | Bin 0 -> 844 bytes app/assets/ollama_icon_16x16Template.png | Bin 403 -> 0 bytes app/assets/ollama_icon_16x16Template@2x.png | Bin 741 -> 0 bytes .../ollama_outline_icon_16x16Template.png | Bin 445 -> 0 bytes app/forge.config.ts | 8 +- app/src/index.ts | 102 ++++++++++-------- scripts/publish.sh | 5 +- 10 files changed, 62 insertions(+), 53 deletions(-) create mode 100644 app/assets/iconTemplate.png rename app/assets/{ollama_outline_icon_16x16Template@2x.png => iconTemplate@2x.png} (100%) create mode 100644 app/assets/iconUpdateTemplate.png create mode 100644 app/assets/iconUpdateTemplate@2x.png delete mode 100644 app/assets/ollama_icon_16x16Template.png delete mode 100644 app/assets/ollama_icon_16x16Template@2x.png delete mode 100644 app/assets/ollama_outline_icon_16x16Template.png diff --git a/app/assets/iconTemplate.png b/app/assets/iconTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..7b0882546cdb521c7636bcf4dc6dcebf50e6e65f GIT binary patch literal 447 zcmV;w0YLtVP)MiLSOp88`^^WyXCvXLG{7^Reaij zM%>#w%lNi@9yfkaT~MTi2)&p_tL1g@o)zf9k{^@{if9*;=FFBcj7uzH1{Fz(ek*c- zmEf6nv|yd;zKkUmImfPK#}3Lq;rHZ8;MtLE=*> zSZ>WG(miU%Ee7%IJMl-X_hJsS7_#MQfhL<>_hKCa pLr<)n)QNsz70He-N!gQs#}6K(KN!n|$guzb002ovPDHLkV1hFm$wB}C literal 0 HcmV?d00001 diff --git a/app/assets/ollama_outline_icon_16x16Template@2x.png b/app/assets/iconTemplate@2x.png similarity index 100% rename from app/assets/ollama_outline_icon_16x16Template@2x.png rename to app/assets/iconTemplate@2x.png diff --git a/app/assets/iconUpdateTemplate.png b/app/assets/iconUpdateTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..fa9d715812e161a65971d6ab209bd49f91e88bdd GIT binary patch literal 443 zcmV;s0Yv_ZP)UqK~#7Ft<%3N zMPV4g@rQc{gLI|DqBF>3xI|KlMFs;4S>zU*k&?}S;Q9wHHX8?deR3|4)iB lP26(b{Rq%6e((M#z5xc(NGDo69w7h#002ovPDHLkV1k=-`;1Pwbx#I1OEX=B+v{K9ujU9 z_6qwFjM*>To@SzG(Di+HTZ{tDNY*(Btzr z;e-nM%hWs*ZZr-}jQIwJBOXg=Zwhbmd6aNIp9|zzwinT=_L1;A+l{CJ!Jlkk`z^u{ zmrZ~4T?_RkwhzR8q*^2b{G|O#Tg2Z>V&4tWexR+ie19+!@fe_H6a27G<9kg~-38Z# zgTjTvGqj4$bbN-4qHXuYUM zN*p&6w4%zI#-Isda=uD4&tzdg2cAalm}TZWnsm?(gi)A@d~g9V)zh^*f&%preh3xo zg=2(w*q$mpNUc`G9{4$Qo&A%9>x3Qr_!GXLi-b7FfltlAATnC{^h6E9`$hQK^moyz z=WL(n94&0WbA8ZNtX|U=gmuCdrf;e6BK&M`5RMm)gTL;2ZfJdIhrcrv%W2opmXHvd z!GrYt2;XVw_XuzEeL*-{_yB&yJnHVUf3@(GaDn+DPuyg*nTEj0P`{3x)!7entCx)djn0~RApw6&4GqH%5u{9|3Of4Y@hD>zV3=K?0G zoVyU-j9jqQGhjWM+L4rQAb7-1qcAw4{}lQ&8)Zj#3osZDwhwJ0FG zM^s|m4Gq(cumRbj^`M-^0Y#$`XNf{JN6JW0uy#}2k9^>zbwIJq3|fhN;L!nRlK%$h W0P|S^muvd~0000P)g3Usuz1!C+9}06+M^2p)9K zE}EJj#+_d<5ELk(hFNTxUA*HIIm~OpP7DPFzEH%Rq+6K4Hhys}JtB{9wEA%8uo5e9 zlVP!U9&2Gye^0Q4M;vP_dy<@sd;2~Lu>v)1;}sRn9pN8Wc*DAx+X;J(Mpk8#*nIyg2XJx<0?!ZkhnEwkZ x7F9pUndGx%kEd9&EZM(<%h(S7BzuhdK^sr?R<%cVjC=q9002ovPDHLkV1mY!rJMi& diff --git a/app/assets/ollama_icon_16x16Template@2x.png b/app/assets/ollama_icon_16x16Template@2x.png deleted file mode 100644 index 1a94c9e27d9b7ba048ff37175c37d5f3be18e322..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 741 zcmV z732f?fhLqEZ^(b;8Oa6g=R5YVbV8|hP91%>oE{C>A5@!P$bB0{h@^HZZ zsoD&Zel0&nO65^r^?I^f%M)Y?;YX4Uh~ z0(y}`1k)1ZX4ZbK?>1n$|dQiSh!{jP?0h4m&p*mvy zJ_3^)wmW`$5TRSB+_ph&?;v9^`M#taDj%og)L13@wFvp z0&*|L;E!cdpVmL>fCU1O59Dp@Dz{3Asaoz6TIaL}%R&z9X1}+LG-) zPj-0Bh2W}ucjl>wq4R+(VRZnu2d^;eY)I(^! zuEZKHf(fry?|>w?PIoZh4s1gBTQRL932i{c1lA%utwF>Dn)+X^j^-j_0kHpvaqnQU{bbt zDGOQnp61+K*St6H)~9C9%sKbmduK%ck52TZ#5*d){|tTM18-;x;_nvk_7m!Z0;~A6 zmm6_!?=0in;yK*7gu0+W5ixo(jaG|m;+`e?k8(wtfA!??sEW>A(2qu&Y~ zU?q5_oh(>~x({P%1 autoUpdater.quitAndInstall(), } - tray = new Tray(iconPath) + const menuItemUpToDate: MenuItemConstructorOptions = { + label: 'Ollama is up to date', + enabled: false, + } - nativeTheme.on('updated', function theThemeHasChanged() { - if (nativeTheme.shouldUseDarkColors) { - app.isPackaged - ? tray.setImage(path.join(process.resourcesPath, 'ollama_icon_16x16Template.png')) - : tray.setImage(path.join(__dirname, '..', '..', 'assets', 'ollama_icon_16x16Template.png')) - } else { - app.isPackaged - ? tray.setImage(path.join(process.resourcesPath, 'ollama_outline_icon_16x16Template.png')) - : tray.setImage(path.join(__dirname, '..', '..', 'assets', 'ollama_outline_icon_16x16Template.png')) - } - }) + const menu = Menu.buildFromTemplate([ + ...(updateAvailable + ? [{ label: 'An update is available', enabled: false }, menuItemAvailable] + : [menuItemUpToDate]), + { type: 'separator' }, + { role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' }, + ]) - const contextMenu = Menu.buildFromTemplate([{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' }]) + const iconPath = app.isPackaged + ? updateAvailable + ? path.join(process.resourcesPath, 'iconUpdateTemplate.png') + : path.join(process.resourcesPath, 'iconTemplate.png') + : updateAvailable + ? path.join(__dirname, '..', '..', 'assets', 'iconUpdateTemplate.png') + : path.join(__dirname, '..', '..', 'assets', 'iconTemplate.png') - tray.setContextMenu(contextMenu) - tray.setToolTip('Ollama') + if (!tray) { + tray = new Tray(iconPath) + } + + tray.setToolTip(updateAvailable ? 'An update is available' : 'Ollama') + tray.setContextMenu(menu) + tray.setImage(iconPath) } if (require('electron-squirrel-startup')) { @@ -128,6 +145,17 @@ if (process.platform === 'darwin') { } app.on('ready', () => { + setTray(false) + + if (app.isPackaged) { + heartbeat() + autoUpdater.checkForUpdates() + setInterval(() => { + heartbeat() + autoUpdater.checkForUpdates() + }, 60 * 60 * 1000) + } + if (process.platform === 'darwin') { if (app.isPackaged) { if (!app.isInApplicationsFolder()) { @@ -163,7 +191,6 @@ app.on('ready', () => { } } - createSystemtray() server() if (store.get('first-time-run') && installed()) { @@ -201,29 +228,10 @@ async function heartbeat() { }) } -if (app.isPackaged) { - heartbeat() - autoUpdater.checkForUpdates() - setInterval(() => { - heartbeat() - autoUpdater.checkForUpdates() - }, 60 * 60 * 1000) -} - autoUpdater.on('error', e => { console.error(`update check failed - ${e.message}`) }) -autoUpdater.on('update-downloaded', (_, 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() - }) +autoUpdater.on('update-downloaded', () => { + setTray(true) }) diff --git a/scripts/publish.sh b/scripts/publish.sh index afd2b2ac..63e5ea0c 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -17,15 +17,16 @@ npm --prefix app run make:sign # Create a new tag if it doesn't exist. if ! git rev-parse v$VERSION >/dev/null 2>&1; then git tag v$VERSION - git push origin v$VERSION fi +git push origin v$VERSION + mkdir -p dist cp app/out/make/zip/${OS}/${ARCH}/Ollama-${OS}-${ARCH}-${VERSION}.zip dist/Ollama-${OS}-${ARCH}.zip cp ./ollama dist/ollama-${OS}-${ARCH} # Create a new release. -gh release create -p v$VERSION +gh release create -p v$VERSION -t v$VERSION # Upload the zip file. gh release upload v$VERSION ./dist/Ollama-${OS}-${ARCH}.zip