[RCD] Threaded message listing implementation

Nathan Kinkade nath at nkinka.de
Mon Mar 16 15:02:52 CET 2009

On Mon, 16 Mar 2009 12:50:55 +0000, Chris January <chris at atomice.net>
> May I ask what is the rationale behind the second patch?
> I took a look at all three patches and the follow up. I think the idea
> of a 'default' sort order is a good one. I have been testing the
> threading implementation with a 70,000+ message mailbox and having the
> option to set the sort order to 'default' should improve load times
> even if threading is turned off.
> I would like to integrate this with the GUI so that, e.g. clicking the
> Date column toggles between ascending, descending and 'default' (since
> the default sort order sorts by date in some fashion).
> I also saw you had tweaked which messages are expanded by default. My
> personal preference is to use a slightly different algorithm, namely:
> unread = collapsed
> read + any descendants unread = expanded
> read + all descendants read = collapsed
> This assumes the threads you are interested in are the ones you have
> read. If any new replies are added to those threads you want to see
> them. However threads where you have not read the root of are probably
> not interesting so shouldn't be expanded.
> Cheers,
> Chris

Sorry, I should have explained some of the changes a little more.  The 2nd
patch is there because the default behavior of RoundCube is to store any
sort order you select in both the session and in the database.  With
X-REFERENCES2, and presumably any other similar algorithms, there really is
no sorting needed on the client side by default.  However, I had no way to
tell RoundCube to drop what it had stored and do no sorting at all.  That
is, once a sort order gets saved in the database you seem to be locked in
to sort fields/orders that are available through the interface and there
was no obvious way to make it forget that and just let the server do all
the sorting.  In my case, 99.99% of the time I'm going to want to sort DESC
by date, but in the special way that X-REFERENCES2 implements it.  The 2nd
patch just means that if you do a special sorting through the interface
that it will only implement it until you make some other action, at which
point it will just automatically revert to no sort, letting the IMAP
server do it's thing.

About the expanding of messages: my intention is that any thread with an
unread message will be expanded as necessary to reveal the unread message. 
If it encounters sub-threads along the way whose children are all read then
it will leave that sub-thread collapsed.  Basically, expand as necessary so
that no unread messages is ever hidden, yet only expand just enough so that
this is true.  It seems to be working fine.

A note about my follow up message.  I was incorrect.  The follow up patch I
sent caused it appear to start working, but on closer inspection later, the
sorting was not quite correct. The problem I was experiencing was like
this: a folder seems to be working fine, the INBOX, for example, but as
soon I would move a message from there to another folder suddenly RoundCube
would tell me that there were no messages in the INBOX, yet the unread
count next to the folder name would reveal the truth.  I still haven't 100%
figured it out, but it's related to the value of $max that gets set around
line 590 of ./program/include/rcube_imap.php.  That $max value when using
the X-REFERENCES algorithm gets set to a value 1 greater than the actual
correct number, because the function iil_C_Thread() seems to be returning
this spurious value.  I can get around the problem in one of two ways for
now: 1) delete the files dovecot.* in the actual INBOX maildir directory 2)
set $max = $this->_messagecount($mailbox, 'ALL');, which seems to work fine
even with the threaded implementation.  Any thoughts on this?

List info: http://lists.roundcube.net/dev/

More information about the Dev mailing list