From 2b64ec5375ebef61a32d5a2612860f8542745cf9 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Wed, 12 Jan 2022 15:19:18 +0100 Subject: [PATCH] Fix null ref when building/updating the MenuBar (#1227) --- src/main/menubar.ts | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/main/menubar.ts b/src/main/menubar.ts index f87e686ef5..ea27f49f88 100644 --- a/src/main/menubar.ts +++ b/src/main/menubar.ts @@ -52,6 +52,15 @@ export class Menubar { appVersion: string, updateRequest?: MenuUpdateRequest ) { + let isLocked = true; + if ( + updateRequest != null && + updateRequest.accounts != null && + updateRequest.activeUserId != null + ) { + isLocked = updateRequest.accounts[updateRequest.activeUserId]?.isLocked ?? true; + } + this.items = [ new BitwardenMenu( i18nService, @@ -60,28 +69,10 @@ export class Menubar { windowMain.win, updateRequest?.accounts ), - new FileMenu( - i18nService, - messagingService, - updateRequest?.accounts[updateRequest?.activeUserId]?.isLocked ?? true - ), - new EditMenu( - i18nService, - messagingService, - updateRequest?.accounts[updateRequest?.activeUserId]?.isLocked ?? true - ), - new ViewMenu( - i18nService, - messagingService, - updateRequest?.accounts[updateRequest?.activeUserId]?.isLocked ?? true - ), - new AccountMenu( - i18nService, - messagingService, - webVaultUrl, - windowMain.win, - updateRequest?.accounts[updateRequest?.activeUserId]?.isLocked ?? true - ), + new FileMenu(i18nService, messagingService, isLocked), + new EditMenu(i18nService, messagingService, isLocked), + new ViewMenu(i18nService, messagingService, isLocked), + new AccountMenu(i18nService, messagingService, webVaultUrl, windowMain.win, isLocked), new WindowMenu(i18nService, messagingService, windowMain), new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain), new HelpMenu(i18nService, webVaultUrl),