madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20435: LJSUP-10218: Pagination is incorrect on ...

Committer: sbelyaev
LJSUP-10218: Pagination is incorrect on resent entries page (S1 style)
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2011-10-26 09:13:56 UTC (rev 20434)
+++ trunk/cgi-bin/ljviews.pl	2011-10-26 10:05:25 UTC (rev 20435)
@@ -1210,21 +1210,34 @@
     
     my $delayed_entries;
 
+    # calculate recent entries count
+    my $has_sticky = $u->has_sticky_entry;
+    my $delayed_entries_count = 0;
+    my $usual_skip = $skip;
+
     if (LJ::is_enabled("delayed_entries")) {
-        if ($u->has_sticky_entry && !$skip) {
-            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow - 1);
+        $delayed_entries_count = LJ::DelayedEntry->get_entries_count($u);
+        $usual_skip -= $delayed_entries_count;
+
+        if ($usual_skip < 0 ) {
+            $usual_skip = $skip ? $has_sticky : 0;
+        }
+
+        if ($skip) {
+            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip - $has_sticky, $itemshow);
         } else {
-            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow + 1);
+            $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow - $has_sticky);
         }
     }
-    
+
+
     if (!$delayed_entries) {
         $delayed_entries = [];
     }
 
     my $itemshow_usual = $itemshow - scalar(@$delayed_entries);
-    if ( $itemshow <= scalar(@$delayed_entries) ) {
-       $itemshow_usual = -1;
+    if ( $itemshow_usual < 0 ) {
+        $itemshow_usual = 0;
     }
 
     ## load the itemids

Tags: livejournal, madeon, pl, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments