Bug #265548 --> Virtual Folders don't remember the previously selected message

Only works for single folder virtual folders.

sr=bienvenu
This commit is contained in:
scott%scott-macgregor.org 2004-10-30 04:02:10 +00:00
Родитель 027f18cc15
Коммит 43e1240fe8
3 изменённых файлов: 52 добавлений и 86 удалений

Просмотреть файл

@ -100,6 +100,49 @@ function SelectAndScrollToKey(aMsgKey)
return true; 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 = 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 // the folderListener object
var folderListener = { var folderListener = {
OnItemAdded: function(parentItem, item) { }, OnItemAdded: function(parentItem, item) { },
@ -128,7 +171,7 @@ var folderListener = {
var uri = folder.URI; var uri = folder.URI;
var rerootingFolder = (uri == gCurrentFolderToReroot); var rerootingFolder = (uri == gCurrentFolderToReroot);
if (rerootingFolder) { if (rerootingFolder) {
viewDebug("uri = gCurrentFolderToReroot, setting gQSViewIsDirty\n"); viewDebug("uri = gCurrentFolderToReroot, setting gQSViewIsDirty\n");
gQSViewIsDirty = true; gQSViewIsDirty = true;
gCurrentFolderToReroot = null; gCurrentFolderToReroot = null;
var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder); var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
@ -181,53 +224,10 @@ var folderListener = {
} }
} }
if (uri == gCurrentLoadingFolderURI) { if (uri == gCurrentLoadingFolderURI) {
// NOTE,
// if you change the scrolling code below,
// double check the scrolling logic in
// searchBar.js, restorePreSearchView()
viewDebug("uri == current loading folder uri\n"); viewDebug("uri == current loading folder uri\n");
gCurrentLoadingFolderURI = ""; gCurrentLoadingFolderURI = "";
// if we didn't just scroll, scrolled = ScrollToMessageAfterFolderLoad(msgFolder);
// 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()
SetBusyCursor(window, false); SetBusyCursor(window, false);
} }

Просмотреть файл

@ -119,6 +119,9 @@ var gSearchNotificationListener =
vFolder.updateSummaryTotals(true); // force update from db. vFolder.updateSummaryTotals(true); // force update from db.
var msgdb = vFolder.getMsgDatabase(msgWindow); var msgdb = vFolder.getMsgDatabase(msgWindow);
msgdb.Commit(MSG_DB_LARGE_COMMIT); msgdb.Commit(MSG_DB_LARGE_COMMIT);
// now that we have finished loading a virtual folder, scroll to the correct message
ScrollToMessageAfterFolderLoad(vFolder);
} }
}, },
@ -315,43 +318,8 @@ function restorePreSearchView()
ClearMessagePane(); ClearMessagePane();
} }
// NOTE,
// if you change the scrolling code below,
// double check the scrolling logic in
// msgMail3PaneWindow.js, "FolderLoaded" event code
if (!scrolled) if (!scrolled)
{ ScrollToMessageAfterFolderLoad(null);
// 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
} }
function onSearch(aSearchTerms) function onSearch(aSearchTerms)

Просмотреть файл

@ -981,8 +981,6 @@ nsresult nsMsgDBView::UpdateDisplayMessage(nsMsgViewIndex viewPosition)
nsCOMPtr <nsIMsgDBHdr> msgHdr; nsCOMPtr <nsIMsgDBHdr> msgHdr;
rv = GetMsgHdrForViewIndex(viewPosition, getter_AddRefs(msgHdr)); rv = GetMsgHdrForViewIndex(viewPosition, getter_AddRefs(msgHdr));
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgFolder> folder;
GetMsgFolder(getter_AddRefs(folder));
nsXPIDLString subject; nsXPIDLString subject;
FetchSubject(msgHdr, m_flags[viewPosition], getter_Copies(subject)); FetchSubject(msgHdr, m_flags[viewPosition], getter_Copies(subject));
@ -991,11 +989,11 @@ nsresult nsMsgDBView::UpdateDisplayMessage(nsMsgViewIndex viewPosition)
rv = msgHdr->GetStringProperty("keywords", getter_Copies(keywords)); rv = msgHdr->GetStringProperty("keywords", getter_Copies(keywords));
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
mCommandUpdater->DisplayMessageChanged(folder, subject, keywords); mCommandUpdater->DisplayMessageChanged(m_viewFolder, subject, keywords);
if (folder) if (m_viewFolder)
{ {
rv = folder->SetLastMessageLoaded(m_keys[viewPosition]); rv = m_viewFolder->SetLastMessageLoaded(m_keys[viewPosition]);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
} }
} // if view position is valid } // if view position is valid