]> git.wh0rd.org - tt-rss.git/commitdiff
moveToPost: fix when duplicate article IDs are present in the buffer
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 12 Mar 2012 09:53:10 +0000 (13:53 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 12 Mar 2012 09:53:10 +0000 (13:53 +0400)
js/viewfeed.js

index 880abc6bd66c521f6cba2e3e2ea9fdafb38502a6..aac5019b184a4d40d1deecf22e6d2402ac9bd5a1 100644 (file)
@@ -493,13 +493,22 @@ function moveToPost(mode) {
                }
 
                if (active_post_id == false) {
-                       next_id = getFirstVisibleHeadlineId();
-                       prev_id = getLastVisibleHeadlineId();
+                       next_id = rows[0];
+                       prev_id = rows[rows.length-1]
                } else {
                        for (var i = 0; i < rows.length; i++) {
                                if (rows[i] == active_post_id) {
-                                       prev_id = rows[i-1];
-                                       next_id = rows[i+1];
+
+                                       // Account for adjacent identical article ids.
+                                       if (i > 0) prev_id = rows[i-1];
+
+                                       for (var j = i+1; j < rows.length; j++) {
+                                               if (rows[j] != active_post_id) {
+                                                       next_id = rows[j];
+                                                       break;
+                                               }
+                                       }
+                                       break;
                                }
                        }
                }