]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: correctly pick latest in index anchor links
authorEric Wong <e@80x24.org>
Thu, 1 Oct 2015 05:57:19 +0000 (05:57 +0000)
committerEric Wong <e@80x24.org>
Thu, 1 Oct 2015 05:58:06 +0000 (05:58 +0000)
The last message in a thread _display_ is not necessarily the
latest message in the thread.  We must go by the Date: header
on the messages themselves as a best-guess.  Of course Date:
headers may lie, but most mail clients trust them by default,
so we will, too.

lib/PublicInbox/View.pm

index 07023e814516c40862ed32b0c2c86ebe7ba5f4db..ccdcde2a42df8515b3d2a2f69a643ea8c012b93b 100644 (file)
@@ -823,7 +823,10 @@ sub add_topic {
 
                my $u = $x->header('X-PI-From');
                my $ts = $x->header('X-PI-TS');
-               $state->{latest}->{$topic} = [ $mid, $u, $ts ];
+               my $exist = $state->{latest}->{$topic};
+               if (!$exist || $exist->[2] < $ts) {
+                       $state->{latest}->{$topic} = [ $mid, $u, $ts ];
+               }
        } else {
                # ghost message, do not bump level
                $child_adjust = 0;