Bug 1018960 - Make the message about cleaning out Trash or Junk show which folder will actually be cleaned. ui-r=Josiah, r=mkmelin
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -2422,52 +2422,61 @@ let gFolderTreeController = {
return;
}
let array = toXPCOMArray([folder], Ci.nsIMutableArray);
folder.parent.deleteSubFolders(array, msgWindow);
},
/**
- * Prompts the user to confirm and empties the trash for the selected folder
+ * Prompts the user to confirm and empties the trash for the selected folder.
+ * The folder and its children are only emptied if it has the proper Trash flag.
*
* @param aFolder (optional) the trash folder to empty
* @note Calling this function on a non-trash folder will result in strange
* behavior!
*/
emptyTrash: function ftc_emptyTrash(aFolder) {
let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
- if (this._checkConfirmationPrompt("emptyTrash")) {
+ if (!folder)
+ return;
+
+ if (!this._checkConfirmationPrompt("emptyTrash", folder))
+ return;
+
// Check if this is a top-level smart folder. If so, we're going
// to empty all the trash folders.
if (folder.server.hostName == "smart mailboxes" &&
folder.parent.isServer) {
let subFolders = gFolderTreeView
._allFoldersWithFlag(gFolderTreeView._sortedAccounts(),
nsMsgFolderFlags.Trash, false);
- for each (let trash in subFolders)
+ for (let trash of subFolders)
trash.emptyTrash(msgWindow, null);
}
else {
folder.emptyTrash(msgWindow, null);
}
- }
},
/**
- * Deletes everything (folders and messages) in this folder
+ * Deletes everything (folders and messages) in the selected folder.
+ * The folder is only emptied if it has the proper Junk flag.
*
* @param aFolder (optional) the folder to empty
*/
emptyJunk: function ftc_emptyJunk(aFolder) {
const Ci = Components.interfaces;
let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
- if (!this._checkConfirmationPrompt("emptyJunk"))
+ if (!folder || !folder.getFlag(nsMsgFolderFlags.Junk))
+ return;
+
+ if (!this._checkConfirmationPrompt("emptyJunk", folder))
return;
// Delete any subfolders this folder might have
let iter = folder.subFolders;
while (iter.hasMoreElements())
folder.propagateDelete(iter.getNext(), true, msgWindow);
// Now delete the messages
@@ -2561,30 +2570,37 @@ let gFolderTreeController = {
searchMessages: function ftc_searchMessages(aFolder) {
MsgSearchMessages(aFolder || gFolderTreeView.getSelectedFolders()[0]);
},
/**
* Prompts for confirmation, if the user hasn't already chosen the "don't ask
* again" option.
*
- * @param aCommand - the command to prompt for
+ * @param aCommand the command to prompt for
+ * @param aFolder The folder for which the confirmation is requested.
*/
- _checkConfirmationPrompt: function ftc_confirm(aCommand) {
+ _checkConfirmationPrompt: function ftc_confirm(aCommand, aFolder) {
+ // If no folder was specified, reject the operation.
+ if (!aFolder)
+ return false;
+
let showPrompt = true;
try {
showPrompt = !Services.prefs.getBoolPref("mailnews." + aCommand + ".dontAskAgain");
} catch (ex) {}
if (showPrompt) {
let checkbox = {value:false};
let bundle = document.getElementById("bundle_messenger");
+ let title = bundle.getFormattedString(aCommand + "FolderTitle", [aFolder.prettyName]);
+ let msg = bundle.getString(aCommand + "FolderMessage");
let ok = Services.prompt.confirmEx(window,
- bundle.getString(aCommand + "Title"),
- bundle.getString(aCommand + "Message"),
+ title,
+ msg,
Services.prompt.STD_YES_NO_BUTTONS,
null, null, null,
bundle.getString(aCommand + "DontAsk"),
checkbox) == 0;
if (checkbox.value)
Services.prefs.setBoolPref("mailnews." + aCommand + ".dontAskAgain", true);
if (!ok)
return false;
--- a/mail/locales/en-US/chrome/messenger/messenger.properties
+++ b/mail/locales/en-US/chrome/messenger/messenger.properties
@@ -533,21 +533,21 @@ copyToFolderAgainAccessKey=t
alwaysLoadRemoteContentForSender2= Always load remote content from %1$S
#LOCALIZATION NOTE(mdnBarMessageNormal) %1$S is the name of the sender
mdnBarMessageNormal=%1$S has asked to be notified when you read this message.
#LOCALIZATION NOTE(mdnBarMessageAddressDiffers) %1$S is the name of the sender, %2$S is the address(es) to send return receipt to
mdnBarMessageAddressDiffers=%1$S has asked to be notified (on %2$S) when you read this message.
# mailCommands.js
-emptyJunkTitle=Confirm
-emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
+emptyJunkFolderTitle=Empty "%S"
+emptyJunkFolderMessage=Delete all messages and subfolders in the Junk folder?
emptyJunkDontAsk=Don't ask me again.
-emptyTrashTitle=Confirm
-emptyTrashMessage=Are you sure you want to permanently delete all messages and subfolders in the Trash folder?
+emptyTrashFolderTitle=Empty "%S"
+emptyTrashFolderMessage=Delete all messages and subfolders in the Trash folder?
emptyTrashDontAsk=Don't ask me again.
# junkCommands.js
junkAnalysisPercentComplete=Junk analysis %S complete
processingJunkMessages=Processing Junk Messages
# Messenger bootstrapping messages
fileNotFoundTitle = File Not Found