-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable check for update on all supported platforms (janhq#1626)
* fix: enable check for update on all supported platforms * fix: janhq#1622 - wrong no update dialog present * chore: update user guide url
- Loading branch information
Showing
2 changed files
with
64 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,96 @@ | ||
// @ts-nocheck | ||
import { app, Menu, dialog, shell } from "electron"; | ||
const isMac = process.platform === "darwin"; | ||
const { autoUpdater } = require("electron-updater"); | ||
import { compareSemanticVersions } from "./versionDiff"; | ||
import { app, Menu, dialog, shell } from 'electron' | ||
const isMac = process.platform === 'darwin' | ||
import { autoUpdater } from 'electron-updater' | ||
import { compareSemanticVersions } from './versionDiff' | ||
|
||
const template: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[] = [ | ||
...(isMac | ||
? [ | ||
{ | ||
label: app.name, | ||
submenu: [ | ||
{ role: "about" }, | ||
{ | ||
label: "Check for Updates...", | ||
click: () => | ||
autoUpdater.checkForUpdatesAndNotify().then((e) => { | ||
if ( | ||
!e || | ||
compareSemanticVersions( | ||
app.getVersion(), | ||
e.updateInfo.version | ||
) >= 0 | ||
) | ||
dialog.showMessageBox({ | ||
message: `There are currently no updates available.`, | ||
}); | ||
}), | ||
}, | ||
{ type: "separator" }, | ||
{ role: "services" }, | ||
{ type: "separator" }, | ||
{ role: "hide" }, | ||
{ role: "hideOthers" }, | ||
{ role: "unhide" }, | ||
{ type: "separator" }, | ||
{ role: "quit" }, | ||
], | ||
}, | ||
] | ||
: []), | ||
{ | ||
label: "Edit", | ||
label: app.name, | ||
submenu: [ | ||
{ role: 'about' }, | ||
{ | ||
label: 'Check for Updates...', | ||
click: () => | ||
// Check for updates and notify user if there are any | ||
autoUpdater.checkForUpdatesAndNotify(), | ||
}, | ||
{ type: 'separator' }, | ||
{ role: 'services' }, | ||
{ type: 'separator' }, | ||
{ role: 'hide' }, | ||
{ role: 'hideOthers' }, | ||
{ role: 'unhide' }, | ||
{ type: 'separator' }, | ||
{ role: 'quit' }, | ||
], | ||
}, | ||
{ | ||
label: 'Edit', | ||
submenu: [ | ||
{ role: "undo" }, | ||
{ role: "redo" }, | ||
{ type: "separator" }, | ||
{ role: "cut" }, | ||
{ role: "copy" }, | ||
{ role: "paste" }, | ||
{ role: 'undo' }, | ||
{ role: 'redo' }, | ||
{ type: 'separator' }, | ||
{ role: 'cut' }, | ||
{ role: 'copy' }, | ||
{ role: 'paste' }, | ||
...(isMac | ||
? [ | ||
{ role: "pasteAndMatchStyle" }, | ||
{ role: "delete" }, | ||
{ role: "selectAll" }, | ||
{ type: "separator" }, | ||
{ role: 'pasteAndMatchStyle' }, | ||
{ role: 'delete' }, | ||
{ role: 'selectAll' }, | ||
{ type: 'separator' }, | ||
{ | ||
label: "Speech", | ||
submenu: [{ role: "startSpeaking" }, { role: "stopSpeaking" }], | ||
label: 'Speech', | ||
submenu: [{ role: 'startSpeaking' }, { role: 'stopSpeaking' }], | ||
}, | ||
] | ||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]), | ||
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }]), | ||
], | ||
}, | ||
{ | ||
label: "View", | ||
label: 'View', | ||
submenu: [ | ||
{ role: "reload" }, | ||
{ role: "forceReload" }, | ||
{ role: "toggleDevTools" }, | ||
{ type: "separator" }, | ||
{ role: "resetZoom" }, | ||
{ role: "zoomIn" }, | ||
{ role: "zoomOut" }, | ||
{ type: "separator" }, | ||
{ role: "togglefullscreen" }, | ||
{ role: 'reload' }, | ||
{ role: 'forceReload' }, | ||
{ role: 'toggleDevTools' }, | ||
{ type: 'separator' }, | ||
{ role: 'resetZoom' }, | ||
{ role: 'zoomIn' }, | ||
{ role: 'zoomOut' }, | ||
{ type: 'separator' }, | ||
{ role: 'togglefullscreen' }, | ||
], | ||
}, | ||
{ | ||
label: "Window", | ||
label: 'Window', | ||
submenu: [ | ||
{ role: "minimize" }, | ||
{ role: "zoom" }, | ||
{ role: 'minimize' }, | ||
{ role: 'zoom' }, | ||
...(isMac | ||
? [ | ||
{ type: "separator" }, | ||
{ role: "front" }, | ||
{ type: "separator" }, | ||
{ role: "window" }, | ||
{ type: 'separator' }, | ||
{ role: 'front' }, | ||
{ type: 'separator' }, | ||
{ role: 'window' }, | ||
] | ||
: [{ role: "close" }]), | ||
: [{ role: 'close' }]), | ||
], | ||
}, | ||
{ | ||
role: "help", | ||
role: 'help', | ||
submenu: [ | ||
{ | ||
label: "Learn More", | ||
label: 'Learn More', | ||
click: async () => { | ||
await shell.openExternal("https://jan.ai/"); | ||
await shell.openExternal('https://jan.ai/guides/') | ||
}, | ||
}, | ||
], | ||
}, | ||
]; | ||
] | ||
|
||
export const setupMenu = () => { | ||
const menu = Menu.buildFromTemplate(template); | ||
Menu.setApplicationMenu(menu); | ||
}; | ||
const menu = Menu.buildFromTemplate(template) | ||
Menu.setApplicationMenu(menu) | ||
} |