about summary refs log tree commit homepage
path: root/lib/PublicInbox/Thread.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-08-15 23:41:21 +0000
committerEric Wong <e@80x24.org>2015-08-15 23:45:33 +0000
commitf79d00b03dfa4f3f3c13bee4654d243c1d2fcd97 (patch)
treee618b78931df2d7783e5f3c356fd9ffc5d5fac08 /lib/PublicInbox/Thread.pm
parent226657eb31e326cc8329229e8ba0f63ff4c75083 (diff)
downloadpublic-inbox-f79d00b03dfa4f3f3c13bee4654d243c1d2fcd97.tar.gz
We'll be sharing the same threading, so it makes sense to sort
replies using the same code and message headers without repeating
ourselves.

This also standardizes on sorting on X-PI-TS (Unix epoch in seconds)
instead over using X-PI-Date differently in two different places
Diffstat (limited to 'lib/PublicInbox/Thread.pm')
-rw-r--r--lib/PublicInbox/Thread.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/PublicInbox/Thread.pm b/lib/PublicInbox/Thread.pm
index 7dabf243..58efb8dc 100644
--- a/lib/PublicInbox/Thread.pm
+++ b/lib/PublicInbox/Thread.pm
@@ -12,6 +12,20 @@ if ($Mail::Thread::VERSION <= 2.55) {
         eval q(sub _container_class { 'PublicInbox::Thread::Container' });
 }
 
+sub sort_ts {
+        sort {
+                (eval { $a->topmost->message->header('X-PI-TS') } || 0) <=>
+                (eval { $b->topmost->message->header('X-PI-TS') } || 0)
+        } @_;
+}
+
+sub rsort_ts {
+        sort {
+                (eval { $b->topmost->message->header('X-PI-TS') } || 0) <=>
+                (eval { $a->topmost->message->header('X-PI-TS') } || 0)
+        } @_;
+}
+
 package PublicInbox::Thread::Container;
 use strict;
 use warnings;