From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id F3F712007E for ; Thu, 1 Oct 2015 05:59:20 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] view: correctly pick latest in index anchor links Date: Thu, 1 Oct 2015 05:59:20 +0000 Message-Id: <20151001055920.11639-1-e@80x24.org> List-Id: 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 07023e8..ccdcde2 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -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; -- EW