From d38faf21cc51d0857274cfdad63ece33dd66bcc4 Mon Sep 17 00:00:00 2001 From: Jorg K Date: Thu, 15 Dec 2016 01:29:02 +0100 Subject: [PATCH] Bug 1322838 - Check for selected directory better. r=aceman a=jorgk --- mail/components/addrbook/content/abCommon.js | 14 +++++++------- suite/mailnews/addrbook/abCommon.js | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mail/components/addrbook/content/abCommon.js b/mail/components/addrbook/content/abCommon.js index 4fd2816992..b8b85bd2c3 100644 --- a/mail/components/addrbook/content/abCommon.js +++ b/mail/components/addrbook/content/abCommon.js @@ -66,23 +66,23 @@ var DirPaneController = case "cmd_delete": case "button_delete": { let selectedDir = getSelectedDirectory(); + if (!selectedDir) + return false; let selectedDirURI = selectedDir.URI; // Context-sensitive labels for Edit > Delete menuitem. // We only have ABs or Mailing Lists in the directory pane. // For contacts and mixed selections, the label is set in // ResultsPaneController in abResultsPane.js. - if (command == "cmd_delete" && selectedDir) { + if (command == "cmd_delete") { goSetMenuValue(command, selectedDir.isMailList ? "valueList" : "valueAddressBook"); } - // If there's no directory selected, or if it's one of these special ABs, - // return false to disable deletion. - if (!selectedDir || - (selectedDirURI == kPersonalAddressbookURI) || - (selectedDirURI == kCollectedAddressbookURI) || - (selectedDirURI == (kAllDirectoryRoot + "?"))) + // If it's one of these special ABs, return false to disable deletion. + if (selectedDirURI == kPersonalAddressbookURI || + selectedDirURI == kCollectedAddressbookURI || + selectedDirURI == (kAllDirectoryRoot + "?")) return false; // If the directory is a mailing list, and it is read-only, diff --git a/suite/mailnews/addrbook/abCommon.js b/suite/mailnews/addrbook/abCommon.js index a20db751c9..d011cfe38a 100644 --- a/suite/mailnews/addrbook/abCommon.js +++ b/suite/mailnews/addrbook/abCommon.js @@ -55,19 +55,19 @@ var DirPaneController = case "cmd_delete": case "button_delete": { let selectedDir = getSelectedDirectory(); + if (!selectedDir) + return false; let selectedDirURI = selectedDir.URI; // Context-sensitive labels for Edit > Delete menuitem. - if (command == "cmd_delete" && selectedDir) { + if (command == "cmd_delete") { goSetMenuValue(command, selectedDir.isMailList ? "valueList" : "valueAddressBook"); } - // If there's no directory selected, or if it's one of these special ABs, - // return false to disable deletion. - if (!selectedDir || - (selectedDirURI == kPersonalAddressbookURI) || - (selectedDirURI == kCollectedAddressbookURI)) + // If it's one of these special ABs, return false to disable deletion. + if (selectedDirURI == kPersonalAddressbookURI || + selectedDirURI == kCollectedAddressbookURI) return false; // If the directory is a mailing list, and it is read-only,