user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] searchview: deal with the removal of rsort
Date: Wed, 13 Apr 2016 01:36:27 +0000	[thread overview]
Message-ID: <20160413013627.15322-1-e@80x24.org> (raw)

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 | 19 +++++++++----------
 lib/PublicInbox/View.pm       |  4 ++--
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index ab0ff19..e94a1df 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -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;
 
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index f58099d..ebe82b4 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -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
 }
 
-- 
EW


                 reply	other threads:[~2016-04-13  1:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160413013627.15322-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).