about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-09-07 22:53:15 +0000
committerEric Wong <e@80x24.org>2014-09-07 22:57:58 +0000
commit5074cb81a375a3ee57c5c3c57a9a2298c76a698f (patch)
tree9432f37bbe06dea1e3c79167028fc34007bc4130 /lib
parent09162c93f979e19b23e913fa9ef0deebec146e2f (diff)
downloadpublic-inbox-5074cb81a375a3ee57c5c3c57a9a2298c76a698f.tar.gz
Only root messages should be sorted in reverse chronological order,
child messages should be chronological.  This gives precedence to
_topics_, but also for initial replies.

This improves readability when several messages appear at the same
nesting level, and helps git patch series' appear correctly as:

	[PATCH 0/3] ...
		[PATCH 1/3] ...
		[PATCH 2/3] ...
		[PATCH 3/3] ...

Instead of (what it was previously):

	[PATCH 0/3] ...
		[PATCH 3/3] ...
		[PATCH 2/3] ...
		[PATCH 1/3] ...
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Feed.pm14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 646c85c9..1f1c0d6b 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -77,15 +77,21 @@ sub generate_html_index {
                 $feed_opts->{atomurl} . '" type="application/atom+xml"/>' .
                 '</head><body>' . PRE_WRAP;
 
-        # sort by date, most recent at top
+        # sort child messages in chronological order
         $th->order(sub {
                 sort {
-                        $b->topmost->message->header('X-PI-Date') <=>
-                        $a->topmost->message->header('X-PI-Date')
+                        $a->topmost->message->header('X-PI-Date') <=>
+                        $b->topmost->message->header('X-PI-Date')
                 } @_;
         });
+
         my %seen;
-        dump_msg($_, 0, \$html, time, \%seen) for $th->rootset;
+        # except we sort top-level messages reverse chronologically
+        for (sort { (eval { $b->message->header('X-PI-Date') } || 0) <=>
+                    (eval { $a->message->header('X-PI-Date') } || 0)
+                  } $th->rootset) {
+                dump_msg($_, 0, \$html, time, \%seen);
+        }
 
         Email::Address->purge_cache;