about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-06 21:44:38 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-06 21:45:03 +0000
commitfad9acd35e56a289ade90a62d056b2a6663d448c (patch)
tree74d3203af13690a521d4de54ca2733223e2c389e /lib/PublicInbox/View.pm
parent8f2999546c9447ce2aed48ba4d1192e0058e28a2 (diff)
downloadpublic-inbox-fad9acd35e56a289ade90a62d056b2a6663d448c.tar.gz
Favor simpler internal APIs this time around, this cuts
a fair amount of code out and takes another step towards
removing Xapian as a dependency for v2 repos.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm35
1 files changed, 12 insertions, 23 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index cbed9163..94058ed0 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -58,20 +58,16 @@ sub msg_page {
         my ($ctx) = @_;
         my $mid = $ctx->{mid};
         my $ibx = $ctx->{-inbox};
-        my ($first, $more, $head, $tail, $db);
+        my ($first, $more);
         my $smsg;
         if (my $srch = $ibx->search) {
-                $srch->retry_reopen(sub {
-                        ($head, $tail, $db) = $srch->each_smsg_by_mid($mid);
-                        for (; !defined($first) && $head != $tail; $head++) {
-                                my @args = ($head, $db, $mid);
-                                $smsg = PublicInbox::SearchMsg->get(@args);
-                                $first = $ibx->msg_by_smsg($smsg);
-                        }
-                        if ($head != $tail) {
-                                $more = [ $head, $tail, $db ];
-                        }
-                });
+                my ($id, $prev);
+                $smsg = $srch->next_by_mid($mid, \$id, \$prev);
+                $first = $ibx->msg_by_smsg($smsg) if $smsg;
+                if ($first) {
+                        my $next = $srch->next_by_mid($mid, \$id, \$prev);
+                        $more = [ $id, $prev, $next ] if $next;
+                }
                 return unless $first;
         } else {
                 $first = $ibx->msg_by_mid($mid) or return;
@@ -82,18 +78,11 @@ sub msg_page {
 sub msg_html_more {
         my ($ctx, $more, $nr) = @_;
         my $str = eval {
-                my $smsg;
-                my ($head, $tail, $db) = @$more;
+                my ($id, $prev, $smsg) = @$more;
                 my $mid = $ctx->{mid};
-                for (; !defined($smsg) && $head != $tail; $head++) {
-                        my $m = PublicInbox::SearchMsg->get($head, $db, $mid);
-                        $smsg = $ctx->{-inbox}->smsg_mime($m);
-                }
-                if ($head == $tail) { # done
-                        @$more = ();
-                } else {
-                        $more->[0] = $head;
-                }
+                $smsg = $ctx->{-inbox}->smsg_mime($smsg);
+                my $next = $ctx->{srch}->next_by_mid($mid, \$id, \$prev);
+                @$more = $next ? ($id, $prev, $next) : ();
                 if ($smsg) {
                         my $mime = $smsg->{mime};
                         my $upfx = '../' . mid_escape($smsg->mid) . '/';