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.
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;