Browse Source

add updating of retwisters info of an expanded twist after retwist

readme-update
Simon Grim 6 years ago
parent
commit
f0d81c70ed
  1. 6
      js/interface_common.js
  2. 41
      js/twister_actions.js

6
js/interface_common.js

@ -2462,7 +2462,8 @@ function postSubmit(e, oldLastPostId) { @@ -2462,7 +2462,8 @@ function postSubmit(e, oldLastPostId) {
if (btnPostSubmit.hasClass('with-reference')) {
var doSubmitPost = function (postText, postDataElem) {
newRtMsg($.evalJSON(postDataElem.attr('data-content_to_rt')),
postDataElem.attr('data-content_to_sigrt'), postText);
postDataElem.attr('data-content_to_sigrt'), postText, updateRTsWithOwnOne
);
};
} else {
if (splitedPostsCount > 1) {
@ -2587,7 +2588,8 @@ function retweetSubmit(event) { @@ -2587,7 +2588,8 @@ function retweetSubmit(event) {
var postDataElem = prompt.find('.post-data');
newRtMsg($.evalJSON(postDataElem.attr('data-content_to_rt')),
postDataElem.attr('data-content_to_sigrt'));
postDataElem.attr('data-content_to_sigrt'), '', updateRTsWithOwnOne
);
closePrompt(prompt);
}

41
js/twister_actions.js

@ -145,8 +145,49 @@ function requestRTs(postDataElem) { @@ -145,8 +145,49 @@ function requestRTs(postDataElem) {
);
}
function updateRTsWithOwnOne(req, ret) {
if (!ret || !ret.userpost || !ret.userpost.rt || !ret.userpost.rt.n || !ret.userpost.rt.k)
return;
var postDataElem = getElem('.expanded-post .post-data'
+ '[data-screen-name=\'' + ret.userpost.rt.n + '\']'
+ '[data-id=\'' + ret.userpost.rt.k + '\']');
for (var i = 0; i < postDataElem.length; i++) {
var postStatsElem = postDataElem.eq(i).find('.post-stats');
var statCountValueElem = postStatsElem.find('.stat-count-value');
var avatarRowElem = postStatsElem.find('.avatar-row');
var ownAvatarElem = avatarRowElem.find('[data-peer-alias="' + defaultScreenName + '"]');
if (ownAvatarElem.length) {
if (avatarRowElem.children().length > 1)
ownAvatarElem.prependTo(avatarRowElem);
statCountValueElem.text(parseInt(statCountValueElem.text()) + 1);
continue;
}
appendPeerAvatarToRTsRowElem(defaultScreenName, avatarRowElem);
if (avatarRowElem.children().length === 1) {
statCountValueElem.text('1');
postStatsElem.slideDown('fast');
continue;
}
statCountValueElem.text(parseInt(statCountValueElem.text()) + 1);
avatarRowElem.children().last().prependTo(avatarRowElem);
if (avatarRowElem.children().length > 12)
avatarRowElem.children().eq(12).remove();
}
}
function appendPeerAvatarToRTsRowElem(peerAlias, rowElem) {
var elem = twister.tmpl.avatarTiny.clone(true)
.attr('data-peer-alias', peerAlias)
.attr('href', $.MAL.userUrl(peerAlias))
.appendTo(rowElem)
;

Loading…
Cancel
Save