]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: show most recently updated topics, first
authorEric Wong <e@80x24.org>
Sat, 9 Jul 2016 08:01:17 +0000 (08:01 +0000)
committerEric Wong <e@80x24.org>
Sat, 9 Jul 2016 08:01:17 +0000 (08:01 +0000)
This probably makes the most sense as it's structured like
a changelog.

lib/PublicInbox/View.pm

index 5a312d84ba8d14e45cee9fac410440736aefca47..3b041aab2ae64f0957724ae2e7344209c7573cf6 100644 (file)
@@ -879,14 +879,16 @@ sub acc_topic {
 
 sub dump_topics {
        my ($ctx) = @_;
-       my $order = $ctx->{order}; # [ ts, subj1, subj2, subj3, ... ]
+       my $order = delete $ctx->{order}; # [ ts, subj1, subj2, subj3, ... ]
        if (!@$order) {
                $ctx->{-html_tip} = '<pre>[No topics in range]</pre>';
                return 404;
        }
 
        my @out;
-       foreach my $topic (@$order) {
+
+       # sort by recency, this allows new posts to "bump" old topics...
+       foreach my $topic (sort { $b->[0] <=> $a->[0] } @$order) {
                my ($ts, $n, $seen, $top, @ex) = @$topic;
                @$topic = ();
                next unless defined $top;  # ghost topic