From a4f2d87678fde6d38b9f96de53a54f18f4c063c2 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Mon, 15 Feb 2016 23:53:12 +0500 Subject: [PATCH] add .followers-list updating on twisterFollowingO.knownFollowers updating --- js/interface_common.js | 7 ++++++- js/twister_following.js | 3 +++ js/twister_io.js | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index c5a102a..52c0166 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -572,7 +572,12 @@ function appendKnownFollowersToElem(list) { $.MAL.listLoaded(list); } -function addPeerToFollowersList(list, peerAlias) { +function addPeerToFollowersList(list, peerAlias, isCheckNeeded) { + if (typeof list !== 'object' || !list.length) + return; + if (isCheckNeeded && list.find('li[data-peer-alias="' + peerAlias + '"]').length) + return; + var item = twister.tmpl.followersPeer.clone(true).attr('data-peer-alias', peerAlias); item.find('.alias').text('@' + peerAlias); diff --git a/js/twister_following.js b/js/twister_following.js index 744d974..8573b59 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -132,6 +132,7 @@ TwisterFollowing.prototype = { if (following.indexOf(args.tf.user) > -1) { if (args.tf.knownFollowers.indexOf(args.fu) < 0) { args.tf.knownFollowers.push(args.fu); + addPeerToFollowersList(getElem('.followers-modal .followers-list'), args.fu, true); } } else { if (args.tf.notFollowers.indexOf(args.fu) < 0) { @@ -140,6 +141,8 @@ TwisterFollowing.prototype = { var tmpi = args.tf.knownFollowers.indexOf(args.fu); if (tmpi > -1) { args.tf.knownFollowers.splice(tmpi, 1); + getElem('.followers-modal .followers-list') + .find('li[data-peer-alias="' + args.fu + '"]').remove(); } } $(".open-followers").attr("title", args.tf.knownFollowers.length.toString()); diff --git a/js/twister_io.js b/js/twister_io.js index 7ee31eb..9bf8fc8 100644 --- a/js/twister_io.js +++ b/js/twister_io.js @@ -226,6 +226,7 @@ function getFullname( username, item ){ typeof(twisterFollowingO.followingsFollowings[username]["following"]) !== 'undefined') { if (twisterFollowingO.followingsFollowings[username]["following"].indexOf(defaultScreenName) > -1) { twisterFollowingO.knownFollowers.push(username); + addPeerToFollowersList(getElem('.followers-modal .followers-list'), username, true); twisterFollowingO.save(); item.addClass('isFollowing'); item.attr("title", polyglot.t("follows you")); @@ -235,8 +236,10 @@ function getFullname( username, item ){ if (following.indexOf(args.user) > -1) { item.addClass('isFollowing'); item.attr("title", polyglot.t("follows you")); - if (twisterFollowingO.knownFollowers.indexOf(args.username) < 0) + if (twisterFollowingO.knownFollowers.indexOf(args.username) < 0) { twisterFollowingO.knownFollowers.push(args.username); + addPeerToFollowersList(getElem('.followers-modal .followers-list'), args.username, true); + } } else twisterFollowingO.notFollowers.push(args.username);