1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-09-27 03:53:00 +02:00
bitwarden-desktop/src/main/menu/menu.main.ts

53 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2021-12-20 15:47:17 +01:00
import { app, Menu } from "electron";
2018-02-08 21:58:47 +01:00
2021-12-20 15:47:17 +01:00
import { BaseMenu } from "jslib-electron/baseMenu";
2022-04-05 16:54:44 +02:00
import { Main } from "../../main";
2022-02-24 20:50:19 +01:00
2021-12-20 15:47:17 +01:00
import { MenuUpdateRequest } from "./menu.updater";
import { Menubar } from "./menubar";
2018-02-09 06:21:00 +01:00
2022-02-24 20:50:19 +01:00
const cloudWebVaultUrl = "https://vault.bitwarden.com";
2018-02-19 14:52:53 +01:00
export class MenuMain extends BaseMenu {
2021-12-20 15:47:17 +01:00
constructor(private main: Main) {
super(main.i18nService, main.windowMain);
}
async init() {
this.initContextMenu();
await this.setMenu();
}
async updateApplicationMenuState(updateRequest: MenuUpdateRequest) {
await this.setMenu(updateRequest);
}
private async setMenu(updateRequest?: MenuUpdateRequest) {
Menu.setApplicationMenu(
new Menubar(
this.main.i18nService,
this.main.messagingService,
this.main.updaterMain,
this.windowMain,
await this.getWebVaultUrl(),
app.getVersion(),
updateRequest
).menu
);
}
private async getWebVaultUrl() {
let webVaultUrl = cloudWebVaultUrl;
const urlsObj: any = await this.main.stateService.getEnvironmentUrls();
if (urlsObj != null) {
if (urlsObj.base != null) {
webVaultUrl = urlsObj.base;
} else if (urlsObj.webVault != null) {
webVaultUrl = urlsObj.webVault;
}
}
2021-12-20 15:47:17 +01:00
return webVaultUrl;
}
2018-02-08 19:10:13 +01:00
}