From e17da0ebb3cc525eec1f46b5637be1febf2b68a3 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 19 Apr 2015 14:01:41 -0300 Subject: [PATCH 1/2] use UI language as a first guess for the preferred spam language. (maybe we should add another option for that) --- js/options.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/options.js b/js/options.js index fa615d3..39246e0 100644 --- a/js/options.js +++ b/js/options.js @@ -222,6 +222,9 @@ var TwisterOptions = function() $('#language').val( this.getOption('locLang', 'auto') ); $('#language').on('change', function() { $.Options.setOption('locLang', $(this).val()); + if($(this).val() != 'auto') { + twisterRpc("setpreferredspamlang", [$(this).val()]); + } location.reload(); }) } From e9e80f8bad0843e8fe14a2ebcb9bd8c3bfd3b8ae Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 19 Apr 2015 14:21:34 -0300 Subject: [PATCH 2/2] it's alright to get spam from getposts eventually. that is how it is supposed to work. --- js/twister_timeline.js | 68 ++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index fa928c5..c016166 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -189,44 +189,42 @@ function showPosts(req, posts) var streamItemsParent = $.MAL.getStreamPostsParent(); 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]; - //console.log(post); - var streamPost = postToElem(post, "original", req.getspam); - var timePost = post["userpost"]["time"]; - streamPost.attr("data-time",timePost); - - // post will only be shown if appended to the stream list - var streamPostAppended = false; - - // insert the post in timeline ordered by (you guessed) time - // FIXME: lame! searching everything everytime. please optimize! - var streamItems = streamItemsParent.children(); - if( streamItems.length == 0) { - // timeline is empty - streamItemsParent.append( streamPost ); - streamPostAppended = true; - } else { - var j = 0; - for( 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); - streamPostAppended = true; - break; - } + var post = posts[i]; + //console.log(post); + var streamPost = postToElem(post, "original", req.getspam); + var timePost = post["userpost"]["time"]; + streamPost.attr("data-time",timePost); + + // post will only be shown if appended to the stream list + var streamPostAppended = false; + + // insert the post in timeline ordered by (you guessed) time + // FIXME: lame! searching everything everytime. please optimize! + var streamItems = streamItemsParent.children(); + if( streamItems.length == 0) { + // timeline is empty + streamItemsParent.append( streamPost ); + streamPostAppended = true; + } else { + var j = 0; + for( 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); + streamPostAppended = true; + 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); } }