# HG changeset patch # User Frank-Rainer Grahl # Date 1626019738 -3600 # Parent 421317e374908c76d7acad0714240b66adcf587e Bug 1718839 - Replace obsolete EnsureFolderIndex in suite. r=IanN a=IanN diff --git a/suite/mailnews/content/mailWindowOverlay.js b/suite/mailnews/content/mailWindowOverlay.js --- a/suite/mailnews/content/mailWindowOverlay.js +++ b/suite/mailnews/content/mailWindowOverlay.js @@ -1262,18 +1262,17 @@ BatchMessageMover.prototype = } dstFolder = dstFolder.getChildNamed(folderName); } } if (dstFolder != srcFolder) { // Make sure the target folder is visible in the folder tree. - let folderTree = document.getElementById("folderTree"); - EnsureFolderIndex(folderTree.builderView, dstFolder); + EnsureFolderIndex(gFolderTreeView, dstFolder); // If the source folder doesn't support deleting messages, we // make archive a copy, not a move. MailServices.copy.CopyMessages(srcFolder, moveArray, dstFolder, srcFolder.canDeleteMessages, this, msgWindow, true); return; // continues with OnStopCopy } diff --git a/suite/mailnews/content/msgMail3PaneWindow.js b/suite/mailnews/content/msgMail3PaneWindow.js --- a/suite/mailnews/content/msgMail3PaneWindow.js +++ b/suite/mailnews/content/msgMail3PaneWindow.js @@ -1174,16 +1174,34 @@ function SetNextMessageAfterDelete() // was moved or deleted from the folder. gThreadPaneDeleteOrMoveOccurred = true; gNextMessageViewIndexAfterDelete = treeSelection.currentIndex - NumberOfSelectedMessagesAboveCurrentIndex(treeSelection.currentIndex); } else gNextMessageViewIndexAfterDelete = treeSelection.currentIndex; } +function EnsureFolderIndex(treeView, msgFolder) { + // Try to get the index of the folder in the tree. + let index = treeView.getIndexOfFolder(msgFolder); + if (!index) { + // If we couldn't find the folder, open the parents. + let folder = msgFolder; + while (!index && folder) { + folder = folder.parent; + index = EnsureFolderIndex(treeView, folder); + } + if (index) { + treeView.toggleOpenState(index); + index = treeView.getIndexOfFolder(msgFolder); + } + } + return index; +} + function SelectMsgFolder(msgFolder) { gFolderTreeView.selectFolder(msgFolder); } function SelectMessage(messageUri) { var msgHdr = messenger.msgHdrFromURI(messageUri); if (msgHdr)