+sub mset_thread {
+ my ($ctx, $mset, $q) = @_;
+ my %pct;
+ my $srch = $ctx->{srch};
+ my $msgs = $srch->retry_reopen(sub { [ map {
+ my $i = $_;
+ my $smsg = PublicInbox::SearchMsg->load_doc($i->get_document);
+ $pct{$smsg->mid} = $i->get_percent;
+ $smsg;
+ } ($mset->items) ]});
+ my $r = $q->{r};
+ my $rootset = PublicInbox::SearchThread::thread($msgs,
+ $r ? sort_relevance(\%pct) : *PublicInbox::View::sort_ts,
+ $srch);
+ my $skel = search_nav_bot($mset, $q). "<pre>";
+ my $inbox = $ctx->{-inbox};
+ $ctx->{-upfx} = '';
+ $ctx->{anchor_idx} = 1;
+ $ctx->{cur_level} = 0;
+ $ctx->{dst} = \$skel;
+ $ctx->{mapping} = {};
+ $ctx->{pct} = \%pct;
+ $ctx->{prev_attr} = '';
+ $ctx->{prev_level} = 0;
+ $ctx->{seen} = {};
+ $ctx->{s_nr} = scalar(@$msgs).'+ results';
+
+ # reduce hash lookups in skel_dump
+ $ctx->{-obfuscate} = $ctx->{-inbox}->{obfuscate};
+ PublicInbox::View::walk_thread($rootset, $ctx,
+ *PublicInbox::View::pre_thread);
+
+ @$msgs = reverse @$msgs if $r;
+ my $mime;
+ sub {
+ return unless $msgs;
+ while ($mime = pop @$msgs) {
+ $mime = $inbox->msg_by_smsg($mime) and last;
+ }
+ if ($mime) {
+ $mime = PublicInbox::MIME->new($mime);
+ return PublicInbox::View::index_entry($mime, $ctx,
+ scalar @$msgs);
+ }
+ $msgs = undef;
+ $skel .= "\n</pre>";
+ };