From 17d3d44787928ac1992ee9394346ffba7f0fe7de Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 7 Oct 2019 11:07:26 -0400 Subject: [PATCH] (js) Fix references to mail accounts in popup Fixes #4838 --- .../js/Mailer/Mailer.popup.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/UI/WebServerResources/js/Mailer/Mailer.popup.js b/UI/WebServerResources/js/Mailer/Mailer.popup.js index bcfa6ab870..bbbb126966 100644 --- a/UI/WebServerResources/js/Mailer/Mailer.popup.js +++ b/UI/WebServerResources/js/Mailer/Mailer.popup.js @@ -103,9 +103,9 @@ if ($window && $window.opener && - $window.opener.$mailboxController) { + $window.opener.mailAccounts) { // Mail accounts are available from the parent window - accounts = $window.opener.$mailboxController.accounts; + accounts = Account.$findAll($window.opener.mailAccounts); return $q.when(accounts); } else { @@ -132,9 +132,22 @@ */ stateAccount.$inject = ['$stateParams', 'stateAccounts']; function stateAccount($stateParams, stateAccounts) { - return _.find(stateAccounts, function(account) { + var account, mailboxes; + + account = _.find(stateAccounts, function(account) { return account.id == $stateParams.accountId; }); + if (account) { + // Fetch mailboxes + mailboxes = account.$getMailboxes(); + return mailboxes.then(function () { + return account; + }); + } + else { + // Account not found + return $q.reject("Account " + $stateParams.accountId + " doesn't exist"); + } } /** @@ -170,7 +183,7 @@ } else // Mailbox not found - return $q.reject("Mailbox doesn't exist"); + return $q.reject("Mailbox " + mailboxId + " doesn't exist"); } /**