Browse files

Removed unfollowed users from the DOM on refresh.

  • Loading branch information...
1 parent 991d5f8 commit bdf2032794d67ea969de940fd66ff774b87c0e5d @jjNford committed Mar 13, 2012
Showing with 38 additions and 0 deletions.
  1. +38 −0 js/follows.js
View
38 js/follows.js
@@ -55,6 +55,35 @@
}
}
},
+
+ /**
+ * Clean
+ *
+ * Remove unfollowed users on refresh.
+ *
+ * @param contextId Context ID requesting clean.
+ * @param followers Full list of followers.
+ */
+ clean: function(contextId, followers) {
+ var list = jQuery('.follows_list');
+ var remove = [];
+
+ // Look for DOM items to remove.
+ list.find('.item').each( function() {
+ var item = jQuery(this);
+ for(var i = 0; i < followers.length; i++) {
+ if(item.attr('id') == followers[i].id) {
+ return;
+ }
+ }
+ remove.push(item);
+ });
+
+ // Remove deleted repositories from DOM.
+ for(var i in remove) {
+ remove[i].remove();
+ }
+ },
/**
* List
@@ -230,6 +259,15 @@
// When all user data has been loaded cache the results.
function getComplete() {
cacheBuffer = window[name].filter.data.createdAt(cacheBuffer);
+
+ // Clean unwatched repos from display.
+ Socket.postMessage({
+ namespace: name,
+ literal: "display",
+ method: "clean",
+ args: [context.id, cacheBuffer]
+ });
+
Cache.save(context.id, name, cacheBuffer);
Socket.postTaskComplete();
}

0 comments on commit bdf2032

Please sign in to comment.