]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: improve topic view by scanning for ghosts
authorEric Wong <e@80x24.org>
Mon, 20 Jun 2016 07:22:23 +0000 (07:22 +0000)
committerEric Wong <e@80x24.org>
Mon, 20 Jun 2016 07:22:52 +0000 (07:22 +0000)
This should help avoid having too many fake top-level
messages in the topic view since we only have a partial
window for threading results.

lib/PublicInbox/Search.pm
lib/PublicInbox/SearchMsg.pm
lib/PublicInbox/View.pm

index 856c8c144c8ea1afcb4d0cae2a736ffad4e955ef..8c0bab185d489008356e8efeafa641893549eac7 100644 (file)
@@ -227,6 +227,12 @@ sub lookup_message {
        $smsg;
 }
 
+sub lookup_mail { # no ghosts!
+       my ($self, $mid) = @_;
+       my $smsg = lookup_message($self, $mid);
+       PublicInbox::SearchMsg->load_doc($smsg->{doc});
+}
+
 sub find_unique_doc_id {
        my ($self, $term, $value) = @_;
 
index 28c2037b1a99aef10e783d8b92e2f1039636ac7b..d41d24390eb790c84239d2c096d069cdc0a9b984 100644 (file)
@@ -35,7 +35,7 @@ sub get_val ($$) {
 
 sub load_doc {
        my ($class, $doc) = @_;
-       my $data = $doc->get_data;
+       my $data = $doc->get_data or return;
        my $ts = get_val($doc, &PublicInbox::Search::TS);
        utf8::decode($data);
        my ($subj, $from, $refs, $to, $cc) = split(/\n/, $data);
index 006da8d0637287f7045764757089dc9dc539441b..dfae44f8d4885883117f69e5369ef897e68ff196 100644 (file)
@@ -741,19 +741,27 @@ sub sort_ts {
        } @_;
 }
 
+sub _tryload_ghost ($$) {
+       my ($srch, $node) = @_;
+       my $mid = $node->messageid;
+       my $smsg = $srch->lookup_mail($mid) or return;
+       $smsg->mini_mime;
+}
+
 # accumulate recent topics if search is supported
 # returns 1 if done, undef if not
 sub add_topic {
        my ($state, $node, $level) = @_;
        return unless $node;
        my $child_adjust = 1;
-
-       if (my $x = $node->message) {
+       my $srch = $state->{srch};
+       my $x = $node->message || _tryload_ghost($srch, $node);
+       if ($x) {
                $x = $x->header_obj;
                my $subj;
 
                $subj = $x->header('Subject');
-               $subj = $state->{srch}->subject_normalized($subj);
+               $subj = $srch->subject_normalized($subj);
 
                if (++$state->{subjs}->{$subj} == 1) {
                        push @{$state->{order}}, [ $level, $subj ];