mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 363831: Saved Search with only one folder to search results in endless loading and high CPU load; r=neil, sr=bienvenu
This commit is contained in:
parent
e89d6ad93e
commit
e8ca906fcc
@ -348,10 +348,10 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
|
||||
if (gSearchSession && !gVirtualFolderTerms) // another var might be better...
|
||||
{
|
||||
viewDebug("doing a xf folder search in rerootFolder\n");
|
||||
gDBView.searchSession = gSearchSession;
|
||||
gSearchSession.search(msgWindow);
|
||||
ViewChangeByFolder(newFolder);
|
||||
gPreQuickSearchView = null; // don't remember the cross folder search
|
||||
ScrollToMessageAfterFolderLoad(newFolder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function SwitchView(command)
|
||||
|
@ -277,7 +277,7 @@ var folderListener = {
|
||||
gDefaultSearchViewTerms = null;
|
||||
viewDebug("searching gVirtualFolderTerms\n");
|
||||
gDBView.viewFolder = gMsgFolderSelected;
|
||||
loadVirtualFolder();
|
||||
ViewChangeByFolder(gMsgFolderSelected);
|
||||
}
|
||||
else if (gMsgFolderSelected.flags & MSG_FOLDER_FLAG_VIRTUAL)
|
||||
{
|
||||
|
@ -114,15 +114,6 @@ var gSearchNotificationListener =
|
||||
vFolder.updateSummaryTotals(true); // force update from db.
|
||||
var msgdb = vFolder.getMsgDatabase(msgWindow);
|
||||
msgdb.Commit(MSG_DB_LARGE_COMMIT);
|
||||
|
||||
// load the last used mail view for the folder...
|
||||
var result = GetMailViewForFolder(vFolder);
|
||||
// do this on a timeout so that we don't issue a new search
|
||||
// synchronously with the previous search's onSearchDone notification
|
||||
// because that can cause a confusing sequence of onSearchDone and
|
||||
// onNewSearch notifications.
|
||||
setTimeout(ViewChangeByValue, 0, result);
|
||||
|
||||
// now that we have finished loading a virtual folder, scroll to the correct message
|
||||
ScrollToMessageAfterFolderLoad(vFolder);
|
||||
}
|
||||
@ -672,19 +663,6 @@ function Search(str)
|
||||
onSearchInput(true);
|
||||
}
|
||||
|
||||
// When the front end has finished loading a virtual folder, it calls openVirtualFolder
|
||||
// to actually perform the folder search. We use this method instead of calling Search("") directly
|
||||
// from FolderLoaded in order to avoid moving focus into the search bar.
|
||||
function loadVirtualFolder()
|
||||
{
|
||||
// bit of a hack...if the underlying real folder is loaded with the same view value
|
||||
// as the value for the virtual folder being searched, then ViewChangeByValue
|
||||
// fails to change the view because it thinks the view is already correctly loaded.
|
||||
// so set gCurrentViewValue back to All.
|
||||
gCurrentViewValue = 0;
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
|
||||
// helper methods for the quick search drop down menu
|
||||
function changeQuickSearchMode(aMenuItem)
|
||||
{
|
||||
|
@ -368,8 +368,9 @@ function RerootFolder(uri, newFolder, viewType, viewFlags, sortType, sortOrder)
|
||||
if (gSearchSession && !gVirtualFolderTerms) // another var might be better...
|
||||
{
|
||||
viewDebug("doing a xf folder search in rerootFolder\n");
|
||||
gDBView.searchSession = gSearchSession;
|
||||
gSearchSession.search(msgWindow);
|
||||
ViewChangeByFolder(newFolder);
|
||||
gPreQuickSearchView = null; // don't remember the cross folder search
|
||||
ScrollToMessageAfterFolderLoad(newFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,48 @@ function SelectAndScrollToKey(aMsgKey)
|
||||
return true;
|
||||
}
|
||||
|
||||
// A helper routine called after a folder is loaded to make sure
|
||||
// we select and scroll to the correct message (could be the first new message,
|
||||
// could be the last displayed message, etc.)
|
||||
// returns true if we ended up scrolling to a message
|
||||
function ScrollToMessageAfterFolderLoad (folder)
|
||||
{
|
||||
var scrolled = pref.getBoolPref("mailnews.scroll_to_new_message") &&
|
||||
ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
||||
if (!scrolled && folder && pref.getBoolPref("mailnews.remember_selected_message"))
|
||||
{
|
||||
// if we failed to scroll to a new message,
|
||||
// reselect the last selected message
|
||||
var lastMessageLoaded = folder.lastMessageLoaded;
|
||||
if (lastMessageLoaded != nsMsgKey_None)
|
||||
scrolled = SelectAndScrollToKey(lastMessageLoaded);
|
||||
}
|
||||
|
||||
if (!scrolled)
|
||||
{
|
||||
// if we still haven't scrolled,
|
||||
// scroll to the newest, which might be the top or the bottom
|
||||
// depending on our sort order and sort type
|
||||
if (gDBView.sortOrder == nsMsgViewSortOrder.ascending)
|
||||
{
|
||||
switch (gDBView.sortType)
|
||||
{
|
||||
case nsMsgViewSortType.byDate:
|
||||
case nsMsgViewSortType.byId:
|
||||
case nsMsgViewSortType.byThread:
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.lastMessage, true, false /* selectMessage */);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if still we haven't scrolled,
|
||||
// scroll to the top.
|
||||
if (!scrolled)
|
||||
EnsureRowInThreadTreeIsVisible(0);
|
||||
}
|
||||
return scrolled;
|
||||
}
|
||||
|
||||
// the folderListener object
|
||||
var folderListener = {
|
||||
OnItemAdded: function(parentItem, item) { },
|
||||
@ -198,42 +240,7 @@ var folderListener = {
|
||||
// scroll to the first new message
|
||||
// but don't select it
|
||||
if (!scrolled && pref.getBoolPref("mailnews.scroll_to_new_message"))
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
||||
|
||||
if (!scrolled && pref.getBoolPref("mailnews.remember_selected_message")) {
|
||||
// if we failed to scroll to a new message,
|
||||
// reselect the last selected message
|
||||
var lastMessageLoaded = msgFolder.lastMessageLoaded;
|
||||
if (lastMessageLoaded != nsMsgKey_None) {
|
||||
scrolled = SelectAndScrollToKey(lastMessageLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
if (!scrolled) {
|
||||
// if we still haven't scrolled,
|
||||
// scroll to the newest, which might be the top or the bottom
|
||||
// depending on our sort order and sort type
|
||||
if (gDBView.sortOrder == nsMsgViewSortOrder.ascending) {
|
||||
switch (gDBView.sortType) {
|
||||
case nsMsgViewSortType.byDate:
|
||||
case nsMsgViewSortType.byId:
|
||||
case nsMsgViewSortType.byThread:
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.lastMessage, true, false /* selectMessage */);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if still we haven't scrolled,
|
||||
// scroll to the top.
|
||||
if (!scrolled)
|
||||
EnsureRowInThreadTreeIsVisible(0);
|
||||
}
|
||||
|
||||
// NOTE,
|
||||
// if you change the scrolling code above,
|
||||
// double check the scrolling logic in
|
||||
// searchBar.js, restorePreSearchView()
|
||||
|
||||
scrolled = ScrollToMessageAfterFolderLoad(msgFolder);
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
if (gNotifyDefaultInboxLoadedOnStartup && (folder.flags & 0x1000))
|
||||
@ -261,7 +268,8 @@ var folderListener = {
|
||||
{
|
||||
gDefaultSearchViewTerms = null;
|
||||
viewDebug("searching gVirtualFolderTerms\n");
|
||||
loadVirtualFolder();
|
||||
gDBView.viewFolder = gMsgFolderSelected;
|
||||
ViewChangeByFolder(gMsgFolderSelected);
|
||||
}
|
||||
else if (gMsgFolderSelected.flags & MSG_FOLDER_FLAG_VIRTUAL)
|
||||
{
|
||||
|
@ -85,9 +85,10 @@ var gSearchNotificationListener =
|
||||
statusFeedback.showProgress(0);
|
||||
gStatusBar.setAttribute("mode","normal");
|
||||
gSearchInProgress = false;
|
||||
|
||||
// ### TODO need to find out if there's quick search within a virtual folder.
|
||||
if (gCurrentVirtualFolderUri &&
|
||||
(gSearchInput.value == "" || gSearchInput.showingSearchCriteria))
|
||||
(!gSearchInput || gSearchInput.value == "" || gSearchInput.showingSearchCriteria))
|
||||
{
|
||||
var vFolder = GetMsgFolderFromUri(gCurrentVirtualFolderUri, false);
|
||||
var dbFolderInfo = vFolder.getMsgDatabase(msgWindow).dBFolderInfo;
|
||||
@ -96,6 +97,8 @@ var gSearchNotificationListener =
|
||||
vFolder.updateSummaryTotals(true); // force update from db.
|
||||
var msgdb = vFolder.getMsgDatabase(msgWindow);
|
||||
msgdb.Commit(MSG_DB_LARGE_COMMIT);
|
||||
// now that we have finished loading a virtual folder, scroll to the correct message
|
||||
ScrollToMessageAfterFolderLoad(vFolder);
|
||||
}
|
||||
},
|
||||
|
||||
@ -290,44 +293,7 @@ function restorePreSearchView()
|
||||
else
|
||||
ClearMessagePane();
|
||||
}
|
||||
|
||||
// NOTE,
|
||||
// if you change the scrolling code below,
|
||||
// double check the scrolling logic in
|
||||
// msgMail3PaneWindow.js, "FolderLoaded" event code
|
||||
if (!scrolled)
|
||||
{
|
||||
// if we didn't just scroll,
|
||||
// scroll to the first new message
|
||||
// but don't select it
|
||||
if (pref.getBoolPref("mailnews.scroll_to_new_message"))
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */);
|
||||
if (!scrolled)
|
||||
{
|
||||
// if we still haven't scrolled,
|
||||
// scroll to the newest, which might be the top or the bottom
|
||||
// depending on our sort order and sort type
|
||||
if (sortOrder == nsMsgViewSortOrder.ascending)
|
||||
{
|
||||
switch (sortType)
|
||||
{
|
||||
case nsMsgViewSortType.byDate:
|
||||
case nsMsgViewSortType.byId:
|
||||
case nsMsgViewSortType.byThread:
|
||||
scrolled = ScrollToMessage(nsMsgNavigationType.lastMessage, true, false /* selectMessage */);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if still we haven't scrolled,
|
||||
// scroll to the top.
|
||||
if (!scrolled)
|
||||
EnsureRowInThreadTreeIsVisible(0);
|
||||
}
|
||||
}
|
||||
// NOTE,
|
||||
// if you change the scrolling code above,
|
||||
// double check the scrolling logic in
|
||||
// msgMail3PaneWindow.js, "FolderLoaded" event code
|
||||
ScrollToMessageAfterFolderLoad(null);
|
||||
}
|
||||
|
||||
function onSearch(aSearchTerms)
|
||||
@ -516,16 +482,3 @@ function saveViewAsVirtualFolder()
|
||||
{
|
||||
openNewVirtualFolderDialogWithArgs(gSearchInput.value, gSearchSession.searchTerms);
|
||||
}
|
||||
|
||||
// When the front end has finished loading a virtual folder, it calls openVirtualFolder
|
||||
// to actually perform the folder search. We use this method instead of calling Search("") directly
|
||||
// from FolderLoaded in order to avoid moving focus into the search bar.
|
||||
function loadVirtualFolder()
|
||||
{
|
||||
// bit of a hack...if the underlying real folder is loaded with the same view value
|
||||
// as the value for the virtual folder being searched, then ViewChangeByValue
|
||||
// fails to change the view because it thinks the view is already correctly loaded.
|
||||
// so set gCurrentViewValue back to All.
|
||||
gCurrentViewValue = 0;
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
|
@ -133,12 +133,19 @@ function ViewChangeByValue(aValue)
|
||||
RefreshViewPopup(viewPickerPopup, true);
|
||||
selectedItems = viewPickerPopup.getElementsByAttribute("value", aValue);
|
||||
}
|
||||
label = selectedItems && selectedItems.length && selectedItems[0].label;
|
||||
label = selectedItems && selectedItems.length && selectedItems.item(0).label;
|
||||
}
|
||||
ViewChange(aValue, label);
|
||||
}
|
||||
|
||||
|
||||
function ViewChangeByFolder(aFolder)
|
||||
{
|
||||
var result = GetMailViewForFolder(aFolder);
|
||||
ViewChangeByValue(result);
|
||||
}
|
||||
|
||||
|
||||
function UpdateViewPicker(aValue, aLabel)
|
||||
{
|
||||
var viewPicker = document.getElementById("viewPicker");
|
||||
|
Loading…
Reference in New Issue
Block a user