]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchview: deal with the removal of rsort
authorEric Wong <e@80x24.org>
Wed, 13 Apr 2016 01:35:56 +0000 (01:35 +0000)
committerEric Wong <e@80x24.org>
Wed, 13 Apr 2016 01:35:56 +0000 (01:35 +0000)
Oops.  While we're at it, simplify the calls to do threading
slightly by reducing the places where we touch Mail::Thread
globals.

Fixes: 56164afc2034 (view: allow topics to be "bumped" by new replies)
lib/PublicInbox/SearchView.pm
lib/PublicInbox/View.pm

index ab0ff19a57e8eb9d37c140d06e6a613de06a698b..e94a1dffc9c0b412d50dd08626f8a5225213ab5a 100644 (file)
@@ -150,13 +150,8 @@ sub tdump {
                $m;
        } ($mset->items);
 
-       require PublicInbox::Thread;
-       my $th = PublicInbox::Thread->new(@m);
-       {
-               no warnings 'once';
-               $Mail::Thread::nosubject = 0;
-       }
-       $th->thread;
+       my @rootset;
+       my $th = PublicInbox::View::thread_results(\@m, 0, $q->{r});
        if ($q->{r}) {
                $th->order(sub {
                        sort { (eval { $pct{$b->topmost->messageid} } || 0)
@@ -164,9 +159,13 @@ sub tdump {
                                (eval { $pct{$a->topmost->messageid} } || 0)
                        } @_;
                });
+               @rootset = $th->rootset;
        } else {
-               no warnings 'once';
-               $th->order(*PublicInbox::View::rsort_ts);
+               @rootset = sort {
+                       (eval { $b->topmost->message->header('X-PI-TS') } || 0)
+                               <=>
+                       (eval { $a->topmost->message->header('X-PI-TS') } || 0)
+               } $th->rootset;
        }
 
        my $git = $ctx->{git} ||= PublicInbox::Git->new($ctx->{git_dir});
@@ -178,7 +177,7 @@ sub tdump {
                fh => $fh,
        };
        $ctx->{searchview} = 1;
-       tdump_ent($git, $state, $_, 0) for $th->rootset;
+       tdump_ent($git, $state, $_, 0) for @rootset;
        PublicInbox::View::thread_adj_level($state, 0);
        Email::Address->purge_cache;
 
index f58099d4b384ada646b79928bfb9dd854fdac565..ebe82b49fdddc1ca8551e3706e1c28a92a6504ad 100644 (file)
@@ -726,7 +726,7 @@ sub msg_timestamp {
 }
 
 sub thread_results {
-       my ($msgs, $nosubject) = @_;
+       my ($msgs, $nosubject, $nosort) = @_;
        require PublicInbox::Thread;
        my $th = PublicInbox::Thread->new(@$msgs);
 
@@ -740,7 +740,7 @@ sub thread_results {
        # Keep ghosts with only a single direct child:
        $Mail::Thread::noprune = 1;
        $th->thread;
-       $th->order(*sort_ts);
+       $th->order(*sort_ts) unless $nosort;
        $th
 }