From b5baa8536222c8fb0415d7ec7e1d930217e7a54c Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 14 Nov 2014 17:34:34 -0200 Subject: [PATCH] improving hashtag modal latency --- js/interface_common.js | 9 ++++++--- js/twister_actions.js | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 3ec2e51..58b0b33 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -185,15 +185,18 @@ function openHashtagModalFromSearchHandler(hashtag) $( "."+hashtagModalClass + " h3" ).text( "#" + hashtag ); } -function updateHashtagModal(postboard,hashtag) { +function updateHashtagModal(postboard,hashtag,timeoutArgs) { var $hashtagModalClass = $(".hashtag-modal"); if( !$hashtagModalClass.length || $hashtagModalClass.css("display") == 'none' ) return; var resource = $hashtagModalClass.attr("data-resource"); - requestHashtag(postboard,hashtag,resource); - setTimeout( function() {updateHashtagModal(postboard,hashtag);}, 5000); + requestHashtag(postboard,hashtag,resource,timeoutArgs); + // use extended timeout parameters on modal refresh (requires twister_core >= 0.9.14). + // our first query above should be faster (with default timeoutArgs of twisterd), + // then we may possibly collect more posts on our second try by waiting more. + setTimeout( function() {updateHashtagModal(postboard,hashtag,[10000,2000,3]);}, 5000); } function openMentionsModal(e) diff --git a/js/twister_actions.js b/js/twister_actions.js index 08bbb71..8fa780a 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -298,12 +298,12 @@ function clearHashtagProcessed() { _hashtagPendingPosts = []; } -function requestHashtag(postboard,hashtag,resource) { +function requestHashtag(postboard,hashtag,resource, timeoutArgs) { dhtget( hashtag, resource, "m", function(args, data) { processHashtag(args.postboard, args.hashtag, data); }, {postboard:postboard,hashtag:hashtag}, - [10000,2000,3]); // use extended timeout parameters (requires twister_core >= 0.9.14) + timeoutArgs); } function processHashtag(postboard, hashtag, data) {