From 4ee5ee0bde760d517168df2846ab68e704105e7e Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sat, 9 May 2015 10:08:06 +0500 Subject: [PATCH] fix of ordering in postboard showPosts() --- js/twister_timeline.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index f192aad..ab7c127 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -216,20 +216,23 @@ function showPosts(req, posts) } } if (!streamPostAppended) { + var timeClosest = 0; for (var j = 0; j < streamItems.length; j++) { var streamItem = streamItems.eq(j); - var timeItem = streamItem.attr("data-time"); - if( timeItem == undefined || - timePost > parseInt(timeItem) ) { - // this post in stream is older, so post must be inserted above - streamItem.before(streamPost); - streamItems[streamItems.length] = streamPost[0]; - streamItems.length += 1; - streamPostAppended = true; - streamPost.show(); - break; + var timeItem = parseInt(streamItem.attr("data-time")); + if (timePost > timeItem && timeItem > timeClosest) { + timeClosest = timeItem; + var streamItemClosest = streamItem; } } + if (timeClosest) { + // this post in stream is older, so post must be inserted above + streamItemClosest.before(streamPost); + streamItems[streamItems.length] = streamPost[0]; + streamItems.length += 1; + streamPostAppended = true; + streamPost.show(); + } } } if (!streamPostAppended) {