From 36fa887d4c372f42fed30767b0e2cf288fc8e54c Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Fri, 2 Nov 2018 02:50:12 +0500 Subject: [PATCH] add update retwisters info for all copies of an expanded twist after request of an DHT call in requestRTs() --- js/interface_common.js | 3 ++- js/tmobile.js | 3 ++- js/twister_actions.js | 23 ++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 0c00f27..59e0773 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -1702,7 +1702,7 @@ function postExpandFunction(e, postLi) { // insert replies to this post after requestRepliesAfter(originalLi); // RTs faces and counter - requestRTs(originalPost); + requestRTs(originalPost.attr('data-screen-name'), originalPost.attr('data-id')); } else { postLi.removeClass(openClass); @@ -2791,6 +2791,7 @@ function initInterfaceCommon() { .removeClass('pending').slideDown('fast') ; }) + .closest('.post-data').find('.post-stats').hide() ; $('.post-area-new') .on('click', function(e) {composeNewPost(e, $(this));}) diff --git a/js/tmobile.js b/js/tmobile.js index 25d83ad..8b2f41c 100644 --- a/js/tmobile.js +++ b/js/tmobile.js @@ -182,7 +182,8 @@ var router=new $.mobile.Router( // insert replies to this post after requestRepliesAfter(originalLi); // RTs faces and counter - requestRTs(originalLi.find('.post-data')); + var postDataElem = originalLi.find('.post-data'); + requestRTs(postDataElem.attr('data-screen-name'), postDataElem.attr('data-id')); }); }, newmsg: function(type,match,ui) { diff --git a/js/twister_actions.js b/js/twister_actions.js index f1be20f..cd0ae1b 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -120,10 +120,7 @@ function requestRepliesAfterAll(postLi) } } -function requestRTs(postDataElem) { - var post_n = postDataElem.attr('data-screen-name'); - var post_k = postDataElem.attr('data-id'); - +function requestRTs(post_n, post_k) { if (!post_n || !post_k) return; @@ -132,9 +129,17 @@ function requestRTs(postDataElem) { if (!ret.length) return; - req.find('.stat-count-value').text(ret.length); + var postDataElem = getElem('.expanded-post .post-data' + + '[data-screen-name=\'' + req.post_n + '\']' + + '[data-id=\'' + req.post_k + '\']'); + + if (!postDataElem.length) + return; + + var postStatsElem = postDataElem.find('.post-stats'); + postStatsElem.find('.stat-count-value').text(ret.length); - var avatarRowElem = req.find('.avatar-row').empty(); + var avatarRowElem = postStatsElem.find('.avatar-row').empty(); var avatarsAppended = []; for (var i = 0; i < ret.length && i < 12; i++) { if (avatarsAppended.indexOf(ret[i].userpost.n) !== -1) @@ -144,10 +149,10 @@ function requestRTs(postDataElem) { appendPeerAvatarToRTsRowElem(ret[i].userpost.n, avatarRowElem); } - if (avatarRowElem.children().length) - req.slideDown('fast'); + if (avatarsAppended.length) + postStatsElem.slideDown('fast'); }, - postDataElem.find('.post-stats').hide() + {post_n: post_n, post_k: post_k} ); }