]> Sergey Matveev's repositories - public-inbox.git/commitdiff
thread: fix sorting without topmost
authorEric Wong <e@80x24.org>
Wed, 5 Oct 2016 23:47:28 +0000 (23:47 +0000)
committerEric Wong <e@80x24.org>
Wed, 5 Oct 2016 23:53:35 +0000 (23:53 +0000)
This bug was hidden, and we may not be able to efficiently
implement a topmost subroutine with the hash-based (vs
linked-list) based container for threading in the next
commit.

lib/PublicInbox/SearchView.pm
lib/PublicInbox/View.pm

index ebeb41f7a153ffbd69d137600261a85d5ea5d14e..cfe6dfffa454d14e55cea7d452a1890873a43b2a 100644 (file)
@@ -155,9 +155,8 @@ sub mset_thread {
        $th->thread;
        if ($q->{r}) { # order by relevance
                $th->order(sub {
-                       [ sort { (eval { $pct{$b->topmost->{id}} } || 0)
-                                       <=>
-                               (eval { $pct{$a->topmost->{id}} } || 0)
+                       [ sort { ( $pct{$b->{id}} || 0) <=>
+                                ( $pct{$a->{id}} || 0)
                        } @{$_[0]} ];
                });
        } else { # order by time (default for threaded view)
index 7554d54f87fed1e5089721c1b88a46957c2c8f18..c09b4a22b51e95c05a11a1b9ba701e9e9c9e66e5 100644 (file)
@@ -857,8 +857,8 @@ sub skel_dump {
 
 sub sort_ts {
        [ sort {
-               (eval { $a->topmost->{smsg}->ts } || 0) <=>
-               (eval { $b->topmost->{smsg}->ts } || 0)
+               (eval { $a->{smsg}->ts } || 0) <=>
+               (eval { $b->{smsg}->ts } || 0)
        } @{$_[0]} ];
 }