From f2048388f361daa9ef0a9fcaa2b173a5770197de Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Thu, 13 Mar 2003 21:57:32 +0000 Subject: [PATCH] fix for bug #183331, searchBar.js when restoring a "pre" quick search view, heed a similar scrolling logic that we have for folder loading. for mail views, this means switching back to the "all" view. fix for bug #186504, msgMail3PaneWindow.js when loading a folder, try to scroll to "new" messages first, before "remembering the last selected" message. both fixes by neil@parkwaycc.co.uk. r/sr=sspitzer --- .../resources/content/msgMail3PaneWindow.js | 46 +++++++++++------ mailnews/base/resources/content/searchBar.js | 49 +++++++++++++++++-- 2 files changed, 75 insertions(+), 20 deletions(-) diff --git a/mailnews/base/resources/content/msgMail3PaneWindow.js b/mailnews/base/resources/content/msgMail3PaneWindow.js index 4b03a3c9cdf3..de9ff40c1f4b 100644 --- a/mailnews/base/resources/content/msgMail3PaneWindow.js +++ b/mailnews/base/resources/content/msgMail3PaneWindow.js @@ -183,9 +183,22 @@ var folderListener = { } } if (uri == gCurrentLoadingFolderURI) { + // NOTE, + // if you change the scrolling code below, + // double check the scrolling logic in + // searchBar.js, restorePreSearchView() + gCurrentLoadingFolderURI = ""; + // if we didn't just scroll, + // scroll to the first new message + // but don't select it + if (!scrolled) + 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) { @@ -193,30 +206,31 @@ var folderListener = { } } - // Now let's select the first new message if there is one if (!scrolled) { - // if we didn't just scroll, scroll to the first new message - // don't select it though - scrolled = ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */); - - // if we failed to find a new message, + // 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 (!scrolled) { - 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 (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() + SetBusyCursor(window, false); } if (gNotifyDefaultInboxLoadedOnStartup && (folder.flags & 0x1000)) diff --git a/mailnews/base/resources/content/searchBar.js b/mailnews/base/resources/content/searchBar.js index aa33069c0457..9e902076e634 100644 --- a/mailnews/base/resources/content/searchBar.js +++ b/mailnews/base/resources/content/searchBar.js @@ -218,19 +218,60 @@ function restorePreSearchView() RerootThreadPane(); - //now restore selection + var scrolled = false; + + // now restore selection if (selectedHdr) { gDBView.selectMsgByKey(selectedHdr.messageKey); var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView); var selectedIndex = treeView.selection.currentIndex; - if (selectedIndex >= 0) //scroll + if (selectedIndex >= 0) + { + // scroll EnsureRowInThreadTreeIsVisible(selectedIndex); + scrolled = true; + } else ClearMessagePane(); } - else - ScrollToMessage(nsMsgNavigationType.firstNew, true, false /* selectMessage */); + + // 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 + 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 } function onSearch(aSearchTerms)