From 61c329efedbe4dacdaf72b36ae8ed7112afefdfb Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Mon, 9 Mar 2015 21:55:42 +0500 Subject: [PATCH] deleting posts on unfollowing and exlude user from further getposts calls --- js/interface_home.js | 4 ++++ js/twister_following.js | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/js/interface_home.js b/js/interface_home.js index 1504bee..8effe53 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -139,6 +139,10 @@ var InterfaceFunctions = function() }) .on("eventUnfollow", function(e, user) { $(".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 ).remove(); + }); }); } } diff --git a/js/twister_following.js b/js/twister_following.js index 453fa61..2e50e99 100644 --- a/js/twister_following.js +++ b/js/twister_following.js @@ -86,11 +86,17 @@ TwisterFollowing.prototype = { //activate updating for only one user... i = followingUsers.indexOf(username); - if (i > -1) + if (i > -1) { oneshot = true; - else if (typeof(this.followingsFollowings[username]) !== 'undefined') { - delete this.followingsFollowings[username]; - this.save(); + } else { + if (typeof(this.followingsFollowings[username]) !== 'undefined') { + delete this.followingsFollowings[username]; + this.save(); + } + if (username in _idTrackerMap) + delete _idTrackerMap[username]; + if (username in _lastHaveMap) + delete _lastHaveMap[username]; return; } } @@ -105,6 +111,15 @@ TwisterFollowing.prototype = { if (updated) this.save(); + for (var user in _idTrackerMap) { + if (followingUsers.indexOf(user) < 0) + delete _idTrackerMap[user]; + } + for (var user in _lastHaveMap) { + if (followingUsers.indexOf(user) < 0) + delete _lastHaveMap[user]; + } + for (; i < followingUsers.length; i++) { var ctime = new Date().getTime() / 1000;