From 93320ed25b82664f5373dbd53042a730eaa5bdb2 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sun, 24 May 2015 00:18:06 +0500 Subject: [PATCH] fix to update only user's own following_counter --- js/interface_home.js | 15 ++++++++------- js/twister_following.js | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/js/interface_home.js b/js/interface_home.js index e4e1de9..52e8c2c 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -98,16 +98,17 @@ var InterfaceFunctions = function() { }, {cbFunc:cbFunc, cbArg:cbArg}); $(window) - .on("eventFollow", function(e, user) { - $(".following-count").text(followingUsers.length-1); + .on('eventFollow', function(e, user) { + $('.mini-profile .following-count').text(followingUsers.length - 1); setTimeout(requestTimelineUpdate, 1000, 'latest', postsPerRefresh, [user], promotedPostsOnly); }) - .on("eventUnfollow", function(e, user) { - $(".following-count").text(followingUsers.length-1); + .on('eventUnfollow', function(e, user) { + $('.mini-profile .following-count').text(followingUsers.length - 1); $('.wrapper .postboard .post').each( function() { - if (($(this).find('[data-screen-name="'+user+'"]').length && !$(this).find(".post-retransmited-by").text()) - || $(this).find(".post-retransmited-by").text() == '@'+user) - $( this ).remove(); + var elem = $(this); + if ((elem.find('[data-screen-name="' + user + '"]').length && !elem.find(".post-retransmited-by").text()) + || elem.find(".post-retransmited-by").text() === '@'+user) + elem.remove(); }); }); diff --git a/js/twister_following.js b/js/twister_following.js index 4f31e2c..674a7bd 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -385,10 +385,11 @@ function follow(user, publicFollow, cbFunc, cbArg) { function unfollow(user, cbFunc, cbArg) { //console.log('we are not following @'+user+' anymore'); var i = followingUsers.indexOf(user); - if( i >= 0 ) { - followingUsers.splice(i,1); + if (i >= 0) { + followingUsers.splice(i, 1); twisterFollowingO.update(user); - $(window).trigger("eventUnfollow", user) + // FIXME also need to check list of pending posts to remove from there + $(window).trigger('eventUnfollow', user); } delete _isFollowPublic[user]; saveFollowing(); @@ -816,12 +817,12 @@ function initInterfaceFollowing() { }); $(window) - .on("eventFollow", function(e, user) { - $(".following-count").text(followingUsers.length-1); + .on('eventFollow', function(e, user) { + $('.mini-profile .following-count').text(followingUsers.length - 1); showFollowingUsers(); }) - .on("eventUnfollow", function(e, user) { - $(".following-count").text(followingUsers.length-1); + .on('eventUnfollow', function(e, user) { + $('.mini-profile .following-count').text(followingUsers.length - 1); showFollowingUsers(); }); }