Closed Bug 20385 Opened 21 years ago Closed 17 years ago

Thread View: Sort threads by date of newest message

Categories

(MailNews Core :: Backend, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rzach, Assigned: Bienvenu)

References

(Blocks 1 open bug)

Details

(Keywords: helpwanted)

Attachments

(1 file)

Currently, the thread display is sorted by the date of the first message in the
thread.  It should be possible to sort them by date of newest message per
thread, so that an old thread with a new unread message gets sorted with the
other new unread messages.
Assignee: phil → nobody
Summary: [FEATURE] Thread View: Sort threads by date of newest message → [HELP WANTED] Thread View: Sort threads by date of newest message
Whiteboard: [HELP WANTED]
Move to help wanted list, cc putterman
Keywords: helpwanted
Summary: [HELP WANTED] Thread View: Sort threads by date of newest message → Thread View: Sort threads by date of newest message
Whiteboard: [HELP WANTED]
QA assigned to myself.
Severity: normal → enhancement
*** Bug 126639 has been marked as a duplicate of this bug. ***
*** Bug 122780 has been marked as a duplicate of this bug. ***
The commentary on the "duplicate" bugz contains a lot more meat than is evident
here.
From bug 126639:


Details:
The basic sorting "theme" will be thread.
However the threads should be sorted with respect to their latest mail dates.

It would very handy to have date based thread sorting in mail listing.
Hence we may identify threads with recent mail activity

 bug 122780 has much more information - too much to copy here.
OS: Linux → All
Hardware: PC → All
This bug depends on Bug 72493 "support threaded, sorted view"

I think, currentlly, threads are NOT sorted by any order.
Order depends on the order of messages in the mbox file.
Depends on: 72493
To be more specific about the mechanism I would *like* to see to make top-level
sorting of threads less harmful, I would say:

* The top-level sorting of threads should *not* be done by either the Date
header or the Unread status

* When sorting by date (presuming newly added support for sorting by other
columns makes the next release), each thread should be considered to have the
date of the top Received header (not the Date header -- see bug 78025 for more
on the harmful effects of this behavior) of the most recent message in the
thread.  The threads should then be sorted in accordance with the current
asc/desc preference for the Date column.

* I don't care much about sorting *within* threads, but would be happy with the
most efficient algorithm that respected the current sort column.  In general, it
would be nice for threads to do internal sorting by asc/desc Received dates. 
Others with longer threads may have more specific interests.

Thanks,
  --kirby
Taking - I can't promise to work on this anytime soon, but I'll put it on my
list. Basically, to implement this, we'd add a new sort type, date of newest
message in thread.  To get this attribute, for each message in the view, we'd
need to get the thread, then iterate over the messages in the thread to find the
newest message (the slow part), then return the date of that message as the
attribute value. Then, we'd sort by that attribute. The part about using the
"received" header is really orthogonal - if someone made it so that we parsed
the first received header to calculate the date sent, then this would
automatically use it.
Assignee: nobody → bienvenu
Two toss in my USD0.02 worth, sorting /within/ a thread needs most-importantly
to arrange answers after the questions.  The history of this bug and its
relatives has a good deal of writing about what's involved (IIRC). 
 
Order of receipt cannot be used to infer anything at all.  Sadly, not everyone
synchronizes their pc clock, so the "Date: " header is unreliable.  The
advantage of the eldest "Received: " header is that it is assumed the clock at
the transmitting node is more accurate.  

There was talk about people hacking dates - spam that shows up at the top or
bottom of your inbox.  Of course, anything that shows up as written tomorrow or
from January and unread gets deep-sixed unread: a filter could probably do the
trick but it isn't that frequently a problem.

I understand the issue with the unreliablity of the Received: header, however, I
would still be *very* happy to see threads sorted by the most recent Received:
header; 99% or more of the Received: headers are close enough to correct.
The request for 'sort [threads] by {date of newest message in thread}' is a 
sensible idea, but there are issues of what to do with the display if you're 
viewing the folder/newsgroup when new messages come in.  If an older thread gets 
a new message, should the thread pane be updated to move the entire thread from 
its current location to the end of the pane?  Should an expanded thread be 
collapsed when it is moved, or maintained open?  Or, should a collapsed thread 
be expanded when a new message arrives for it?

If you are currently viewing a message in that thread, should the message pane 
suddenly jump around to keep your message in view while adjusting the order of 
threads?

Right now, the message pane updating is done fairly staticly, with minimum 
updating as new messages arrive; and is sometimes buggy, e.g, bug 93426, bug 
181446.
if you implement my feature request i just send in as bug #218554 (Reversed 
threads) then it will always be sorted right. 
There has been a distinction between having this only for mail vs. news type accounts. This feature 
would be incredibly useful in both. Personally, it would be much more useful in news, as thats 
where I use threading more. I see this feature as very important part of general threading support. 
As for David's thoughts about alternative methods of new message detection. IMHO, the 'sort by 
newest message in thread' is the most useful.
Other potentially useful but unimplemented thread-sortings:
  sort by Number Unread/Total responses -- bug 72251
  sort by Watched/Ignored status -- bug 222238
OK, I have this working now, with one caveat. You have to sort threads by date
to get this working, which means you either need to use the view | sort by |
date menu when already threaded, or use the hidden pref to make it so that
clicking on the column header doesn't do a flat sort if you're currently threaded. 

Just clicking on the thread icon to go into threaded mode still sorts by thread
ID. I can probably fix that to sort by newest msg in thread, but I haven't done
that yet.
Attached patch proposed fixSplinter Review
this patch does three things:
1. Add ability to find the newestMsgDate of a thread. We try to keep this up to
date, but will recalculate it if need be.
2. Add a GetDateInSeconds method to msg hdrs, and use it where appropriate,
since that's really what we're storing in the db anyway (not a PRTime). This
cleans up a lot of the sort code. Other code, like the search code, could be
cleaned up too.
3. If we're sorting threads by date, sort by date of newest msg in thread.
Attachment #135733 - Flags: superreview?(mscott)
fix checked in, will be in tomorrow's build.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
This appears to be working fine for me. Thank-you very much!
Comment on attachment 135733 [details] [diff] [review]
proposed fix

clearing the review request
Attachment #135733 - Flags: superreview?(mscott) → superreview+
Comment on attachment 135733 [details] [diff] [review]
proposed fix

clearing the review request
Blocks: 234690
Blocks: 228435
*** Bug 30747 has been marked as a duplicate of this bug. ***
*** Bug 227722 has been marked as a duplicate of this bug. ***
My version 1.7.2 Mozilla still have this bug.  How could this be fixed?
I am so mad for this poor testing quality.
Actually, it works as described by David Bienvenu (if use the view menu to set
order by date).  However, the settings is not obvious.  I also set the sort
order by received date on the View menu, so that should also do it too (versus
order by date).  However, it did not sort if the message was sorted order by
received date.  This is where my confusion was because I thought I already set
the sort order to received date, but it didn't work.  I think somehow this
should work on both date settings, and make it easy/obvious for new users.
I agree... it should sort this way if one selects by order recieved as well.
Part of the confusion also comes from the fact that ordering date (by clicking
on the column heading) resets threading, and sets the sort order to "order
recieved".  This is confusing. One should be able to have threads kept together,
no matter what other sort criterion one applies, if it makes any sense at all.
(In reply to comment #16)
> OK, I have this working now, with one caveat. You have to sort threads by date
> to get this working, which means you either need to use the view | sort by |
> date menu when already threaded, or use the hidden pref to make it so that
> clicking on the column header doesn't do a flat sort if you're currently
threaded. 
> 
> Just clicking on the thread icon to go into threaded mode still sorts by thread
> ID. I can probably fix that to sort by newest msg in thread, but I haven't done
> that yet.

I tried following these steps in Mozilla 1.7.3 and was able to sort threads by
date of most recent message in thread.  However, when new mail arrives, the
threads don't get resorted right away.  I have to select the sort from View
again to update the sort order.
Product: MailNews → Core
Product: Core → MailNews Core
See bug 262319 - sort by thread fails to resort on new message
You need to log in before you can comment on or make changes to this bug.