Browse Source

add .followers-list updating on twisterFollowingO.knownFollowers updating

readme-update
Simon Grim 9 years ago
parent
commit
a4f2d87678
  1. 7
      js/interface_common.js
  2. 3
      js/twister_following.js
  3. 5
      js/twister_io.js

7
js/interface_common.js

@ -572,7 +572,12 @@ function appendKnownFollowersToElem(list) { @@ -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);

3
js/twister_following.js

@ -132,6 +132,7 @@ TwisterFollowing.prototype = { @@ -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 = { @@ -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());

5
js/twister_io.js

@ -226,6 +226,7 @@ function getFullname( username, item ){ @@ -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 ){ @@ -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);

Loading…
Cancel
Save