From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3297F1FD2D for ; Wed, 2 Sep 2015 06:59:42 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/7] view: pre-anchor entries for flat view Date: Wed, 2 Sep 2015 06:59:37 +0000 Message-Id: <1441177179-16628-6-git-send-email-e@80x24.org> In-Reply-To: <1441177179-16628-1-git-send-email-e@80x24.org> References: <1441177179-16628-1-git-send-email-e@80x24.org> List-Id: This will allow users to navigate the flat view without making extra HTTP requests. --- lib/PublicInbox/View.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 0331b62..98fc133 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -167,9 +167,10 @@ sub emit_thread_html { return missing_thread($cb) if $nr == 0; my $flat = $ctx->{flat}; my $orig_cb = $cb; + my $seen = {}; my $state = { ctx => $ctx, - seen => {}, + seen => $seen, root_anchor => anchor_for($mid), anchor_idx => 0, }; @@ -177,6 +178,7 @@ sub emit_thread_html { require PublicInbox::GitCatFile; my $git = PublicInbox::GitCatFile->new($ctx->{git_dir}); if ($flat) { + pre_anchor_entry($seen, $_) for (@$msgs); __thread_entry(\$cb, $git, $state, $_, 0) for (@$msgs); } else { my $th = thread_results($msgs); @@ -580,6 +582,12 @@ sub thread_html_head { $$cb->write("$s"); } +sub pre_anchor_entry { + my ($seen, $mime) = @_; + my $id = anchor_for($mime->header('Message-ID')); + $seen->{$id} = "#$id"; # save the anchor for children, later +} + sub __thread_entry { my ($cb, $git, $state, $mime, $level) = @_; -- EW