fix 265595 sr=mscott opening the first message in a dummy thread opens a blank window

This commit is contained in:
bienvenu%nventure.com 2004-10-24 00:00:59 +00:00
parent fc211528b0
commit 802e2f4724
3 changed files with 15 additions and 8 deletions

View File

@ -1006,7 +1006,7 @@ nsresult nsMsgDBView::UpdateDisplayMessage(nsMsgViewIndex viewPosition)
// given a msg key, we will load the message for it.
NS_IMETHODIMP nsMsgDBView::LoadMessageByMsgKey(nsMsgKey aMsgKey)
{
return LoadMessageByViewIndex(FindViewIndex(aMsgKey));
return LoadMessageByViewIndex(FindKey(aMsgKey, PR_FALSE));
}
NS_IMETHODIMP nsMsgDBView::LoadMessageByViewIndex(nsMsgViewIndex aViewIndex)
@ -3353,7 +3353,8 @@ nsresult nsMsgDBView::GetLongField(nsIMsgDBHdr *msgHdr, nsMsgViewSortTypeValue s
case nsMsgViewSortType::byDate:
// when sorting threads by date, we want the date of the newest msg
// in the thread
if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay
&& ! (m_viewFlags & nsMsgViewFlagsType::kGroupBySort))
{
nsCOMPtr <nsIMsgThread> thread;
rv = m_db->GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(thread));
@ -3826,7 +3827,12 @@ nsMsgViewIndex nsMsgDBView::FindKey(nsMsgKey key, PRBool expand)
{
nsMsgViewIndex retIndex = nsMsgViewIndex_None;
retIndex = (nsMsgViewIndex) (m_keys.FindIndex(key));
if (key != nsMsgKey_None && retIndex == nsMsgViewIndex_None && expand && m_db)
// for dummy headers, try to expand if the caller says so. And if the thread is
// expanded, ignore the dummy header and return the real header index.
if (retIndex != nsMsgViewIndex_None && m_flags[retIndex] & MSG_VIEW_FLAG_DUMMY && !expand && !(m_flags[retIndex] & MSG_FLAG_ELIDED))
return (nsMsgViewIndex) m_keys.FindIndex(key, retIndex + 1);
if (key != nsMsgKey_None && (retIndex == nsMsgViewIndex_None || m_flags[retIndex] & MSG_VIEW_FLAG_DUMMY)
&& expand && m_db)
{
nsMsgKey threadKey = GetKeyOfFirstMsgInThread(key);
if (threadKey != nsMsgKey_None)
@ -3835,8 +3841,9 @@ nsMsgViewIndex nsMsgDBView::FindKey(nsMsgKey key, PRBool expand)
if (threadIndex != nsMsgViewIndex_None)
{
PRUint32 flags = m_flags[threadIndex];
if ((flags & MSG_FLAG_ELIDED) && NS_SUCCEEDED(ExpandByIndex(threadIndex, nsnull)))
retIndex = FindKey(key, PR_FALSE);
if ((flags & MSG_FLAG_ELIDED) && NS_SUCCEEDED(ExpandByIndex(threadIndex, nsnull))
|| (flags & MSG_VIEW_FLAG_DUMMY))
retIndex = (nsMsgViewIndex) m_keys.FindIndex(key, threadIndex + 1);
}
}
}

View File

@ -224,7 +224,7 @@ protected:
nsMsgKey GetAt(nsMsgViewIndex index) ;
nsMsgViewIndex FindViewIndex(nsMsgKey key)
{return (nsMsgViewIndex) (m_keys.FindIndex(key));}
{return FindKey(key, PR_FALSE);}
nsMsgViewIndex FindHdr(nsIMsgDBHdr *msgHdr);
virtual nsMsgViewIndex FindKey(nsMsgKey key, PRBool expand);
virtual nsresult GetDBForViewIndex(nsMsgViewIndex index, nsIMsgDatabase **db);

View File

@ -427,8 +427,8 @@ NS_IMETHODIMP nsMsgGroupView::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aP
}
else if (rootDeleted)
{
m_keys.SetAt(viewIndexOfThread, m_keys.GetAt(viewIndexOfThread + 1));
OrExtraFlag(viewIndexOfThread, MSG_VIEW_FLAG_DUMMY | MSG_VIEW_FLAG_ISTHREAD);
m_keys.SetAt(viewIndexOfThread - 1, m_keys.GetAt(viewIndexOfThread));
OrExtraFlag(viewIndexOfThread - 1, MSG_VIEW_FLAG_DUMMY | MSG_VIEW_FLAG_ISTHREAD);
}
}
if (!groupThread->m_keys.GetSize())