From 6c074ee45d9948a0900ff6661d2fa3d10f2becdf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 1 Oct 2015 05:57:19 +0000 Subject: view: correctly pick latest in index anchor links 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(-) (limited to 'lib') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 07023e81..ccdcde2a 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; -- cgit v1.2.3-24-ge0c7