Browse Source

it's alright to get spam from getposts eventually.

that is how it is supposed to work.
master
Miguel Freitas 10 years ago
parent
commit
e9e80f8bad
  1. 68
      js/twister_timeline.js

68
js/twister_timeline.js

@ -189,44 +189,42 @@ function showPosts(req, posts)
var streamItemsParent = $.MAL.getStreamPostsParent(); var streamItemsParent = $.MAL.getStreamPostsParent();
for( var i = 0; i < posts.length; i++ ) { for( var i = 0; i < posts.length; i++ ) {
if (req.users.indexOf(posts[i]['userpost']['n']) > -1 || req.getspam) { // FIXME maybe it's unecessary check but currently we got unwanted adverting posts which are coming with requested ones from 'getposts' sometimes var post = posts[i];
var post = posts[i]; //console.log(post);
//console.log(post); var streamPost = postToElem(post, "original", req.getspam);
var streamPost = postToElem(post, "original", req.getspam); var timePost = post["userpost"]["time"];
var timePost = post["userpost"]["time"]; streamPost.attr("data-time",timePost);
streamPost.attr("data-time",timePost);
// post will only be shown if appended to the stream list
// post will only be shown if appended to the stream list var streamPostAppended = false;
var streamPostAppended = false;
// insert the post in timeline ordered by (you guessed) time
// insert the post in timeline ordered by (you guessed) time // FIXME: lame! searching everything everytime. please optimize!
// FIXME: lame! searching everything everytime. please optimize! var streamItems = streamItemsParent.children();
var streamItems = streamItemsParent.children(); if( streamItems.length == 0) {
if( streamItems.length == 0) { // timeline is empty
// timeline is empty streamItemsParent.append( streamPost );
streamItemsParent.append( streamPost ); streamPostAppended = true;
streamPostAppended = true; } else {
} else { var j = 0;
var j = 0; for( j = 0; j < streamItems.length; j++) {
for( j = 0; j < streamItems.length; j++) { var streamItem = streamItems.eq(j);
var streamItem = streamItems.eq(j); var timeItem = streamItem.attr("data-time");
var timeItem = streamItem.attr("data-time"); if( timeItem == undefined ||
if( timeItem == undefined || timePost > parseInt(timeItem) ) {
timePost > parseInt(timeItem) ) { // this post in stream is older, so post must be inserted above
// this post in stream is older, so post must be inserted above streamItem.before(streamPost);
streamItem.before(streamPost); streamPostAppended = true;
streamPostAppended = true; break;
break;
}
} }
} }
if (!streamPostAppended)
streamItemsParent.append( streamPost );
streamPostAppended = true;
streamPost.show();
req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended);
} }
if (!streamPostAppended)
streamItemsParent.append( streamPost );
streamPostAppended = true;
streamPost.show();
req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended);
} }
} }

Loading…
Cancel
Save