From d5dfac5f0a658ee389bb37107621b0b006244d74 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Fri, 9 Mar 2007 07:08:42 +0000 Subject: [PATCH] Bug #373270 --> when running junk mail controls on a specific folder, use msg hdrs instead of relying on view indices which can change when the user changes folders. sr=bienvenu --- mail/base/content/mailCommands.js | 112 +++++++++++------------------- 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/mail/base/content/mailCommands.js b/mail/base/content/mailCommands.js index 313f90bc705..580bf67b608 100644 --- a/mail/base/content/mailCommands.js +++ b/mail/base/content/mailCommands.js @@ -545,44 +545,31 @@ var gJunkmailComponent; /** * Determines the actions that should be carried out on the messages - * that are being marked as junk. + * that are being marked as junk * - * @param aView - * the current message view - * @param aIndices - * the indices of the messages being marked as junk. + * @param aFolder + * the folder with messages being marked as junk * * @return an object with two properties: 'markRead' (boolean) indicating * whether the messages should be marked as read, and 'junkTargetFolder' * (nsIMsgFolder) specifying where the messages should be moved, or * null if they should not be moved. */ -function determineActionsForJunkMsgs(aView, aIndices) +function determineActionsForJunkMsgs(aFolder) { var actions = { markRead: false, junkTargetFolder: null }; - - // we use some arbitrary message to determine the - // message server - var msgURI = aView.getURIForViewIndex(aIndices[0]); - var msgHdr = messenger.messageServiceFromURI(msgURI).messageURIToMsgHdr(msgURI); - var server = msgHdr.folder.server; - - var spamSettings = server.spamSettings; + var spamSettings = aFolder.server.spamSettings; // note we will do moves/marking as read even if the spam // feature is disabled, since the user has asked to use it // despite the disabling - // note also that we will only act on messages which - // _the_current_run_ of the classifier has classified as - // junk, rather than on all junk messages in the folder - actions.markRead = spamSettings.markAsReadOnSpam; actions.junkTargetFolder = null; // move only when the corresponding setting is activated // and the currently viewed folder is not the junk folder. - if (spamSettings.moveOnSpam && !(msgHdr.folder.flags & MSG_FOLDER_FLAG_JUNK)) + if (spamSettings.moveOnSpam && !(aFolder.flags & MSG_FOLDER_FLAG_JUNK)) { var spamFolderURI = spamSettings.spamFolderURI; if (!spamFolderURI) @@ -593,64 +580,53 @@ function determineActionsForJunkMsgs(aView, aIndices) dump('determineActionsForJunkMsgs: no spam folder found, not moving.'); } else - { actions.junkTargetFolder = GetMsgFolderFromUri(spamFolderURI); - } } return actions; } -function performActionsOnJunkMsgs(aIndices) +function performActionsOnJunkMsgs(aFolder, aMsgHdrs) { - if (!aIndices.length) + if (!aMsgHdrs.Count()) return; - var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView); - - var treeSelection = treeView.selection; - treeSelection.clearSelection(); - - // select the messages - for (i=0;i