add auto start menu preference option

This commit is contained in:
Abhinav 2022-08-19 19:38:01 +05:30
parent fae366c828
commit f5ed1c0856
2 changed files with 22 additions and 3 deletions

View file

@ -61,8 +61,8 @@ export function setupMacWindowOnDockIconClick() {
});
}
export function setupMainMenu() {
Menu.setApplicationMenu(buildMenuBar());
export async function setupMainMenu() {
Menu.setApplicationMenu(await buildMenuBar());
}
export function setupMainHotReload() {

View file

@ -7,6 +7,7 @@ import {
} from 'electron';
import { isUpdateAvailable, setIsAppQuitting } from '../main';
import { showUpdateDialog } from './appUpdater';
import autoLauncher from './autoLauncher';
const isMac = process.platform === 'darwin';
@ -92,7 +93,9 @@ export function buildContextMenu(
return contextMenu;
}
export function buildMenuBar(): Menu {
export async function buildMenuBar(): Promise<Menu> {
const isAutoLaunchEnabled = await autoLauncher.isEnabled();
let latestValue = isAutoLaunchEnabled;
const template: MenuItemConstructorOptions[] = [
{
label: 'ente',
@ -105,6 +108,22 @@ export function buildMenuBar(): Menu {
},
]
: []) as MenuItemConstructorOptions[]),
{ type: 'separator' },
{
label: 'Preferences',
submenu: [
{
label: 'Open ente on startup',
type: 'checkbox',
checked: latestValue,
click: () => {
autoLauncher.toggleAutoLaunch();
latestValue = !latestValue;
},
},
],
},
{ type: 'separator' },
...((isMac
? [
{