app: tray cleanup
This commit is contained in:
parent
e751e47d70
commit
d0e934b497
1 changed files with 12 additions and 15 deletions
|
@ -17,6 +17,7 @@ import * as path from 'path'
|
||||||
|
|
||||||
import { analytics, id } from './telemetry'
|
import { analytics, id } from './telemetry'
|
||||||
import { installed } from './install'
|
import { installed } from './install'
|
||||||
|
import { MenuItem } from '@electron/remote'
|
||||||
|
|
||||||
require('@electron/remote/main').initialize()
|
require('@electron/remote/main').initialize()
|
||||||
|
|
||||||
|
@ -74,21 +75,17 @@ function firstRunWindow() {
|
||||||
let tray: Tray | null = null
|
let tray: Tray | null = null
|
||||||
|
|
||||||
function setTray(updateAvailable: boolean) {
|
function setTray(updateAvailable: boolean) {
|
||||||
const menuItemAvailable: MenuItemConstructorOptions = {
|
const updateItems: MenuItemConstructorOptions[] = [
|
||||||
|
{ label: 'An update is available', enabled: false },
|
||||||
|
{
|
||||||
label: 'Restart to update',
|
label: 'Restart to update',
|
||||||
click: () => autoUpdater.quitAndInstall(),
|
click: () => autoUpdater.quitAndInstall(),
|
||||||
}
|
},
|
||||||
|
{ type: 'separator' },
|
||||||
const menuItemUpToDate: MenuItemConstructorOptions = {
|
]
|
||||||
label: 'Ollama is up to date',
|
|
||||||
enabled: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
const menu = Menu.buildFromTemplate([
|
const menu = Menu.buildFromTemplate([
|
||||||
...(updateAvailable
|
...(updateAvailable ? updateItems : []),
|
||||||
? [{ label: 'An update is available', enabled: false }, menuItemAvailable]
|
|
||||||
: [menuItemUpToDate]),
|
|
||||||
{ type: 'separator' },
|
|
||||||
{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' },
|
{ role: 'quit', label: 'Quit Ollama', accelerator: 'Command+Q' },
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -145,8 +142,6 @@ if (process.platform === 'darwin') {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
setTray(false)
|
|
||||||
|
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
heartbeat()
|
heartbeat()
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
|
@ -156,6 +151,8 @@ app.on('ready', () => {
|
||||||
}, 60 * 60 * 1000)
|
}, 60 * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTray(false)
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
if (!app.isInApplicationsFolder()) {
|
if (!app.isInApplicationsFolder()) {
|
||||||
|
|
Loading…
Reference in a new issue