Bk your feed

![your_feed_updated](https://cloud.githubusercontent.com/assets/1451471/3247188/08df7602-f182-11e3-86b8-02d89fc7ea27.gif)
Not sure if this helps you or not, and feel free to disregard this, but I broke it up into some smaller functions to show how it could be done. The benefit of this means that you can give the function useful names (meaning fewer comments) and you can stub out return values of functions in the tests so that you don't really have to care about the inner implementation. Anyway, if it helps... :)

```
UserFeed.prototype._getActivityNumber = function(feed) {
  if (!feed.activities.length) return;

  var newActivitiesCount = 0,
      i = 0;

  for (i; i < feed.activities.length; i++) {
    this._isNewActivity(feed.activities[i].timestamp) && newActivitiesCount++;
  }

  return newActivitiesCount;
};

UserFeed.prototype._isNewActivity = function () {
  for (var j = 0; j < this.oldActivities.length; j++) {
    if ( timestamp == this.oldActivities[j].timestamp ) {
      return false;
    }
  }
  return true;
}

UserFeed.prototype._updateActivities = function() {
  if (this.oldActivities) {
    var newActivitiesCount = this._getActivityNumber(fetchedFeed);

    if (this.highlightedActivitiesNumber < newActivitiesCount) {
      this.highlightedActivitiesNumber = newActivitiesCount;
    }

    newActivitiesCount && this._createUserActivities(fetchedFeed.activities);

  } else {
    // Create activities list
    this._createUserActivities(fetchedFeed.activities, fetchedFeed.activities.length);
    this.oldActivities = fetchedFeed.activities;
  }
};

UserFeed.prototype._updateMessages = function(feed) {
  var newMessagesNumber = feed.unreadMessagesCount;
  
  feed.messages.length && this._createUserMessages(feed.messages, newMessagesNumber);
  this._updateUnreadFeedIndicator(this.highlightedActivitiesNumber + newMessagesNumber);

  // Update timeago for feed content only
  $(this.config.feedSelector + " time.timeago").timeago();
};

UserFeed.prototype._updateFeed = function(fetchedFeed) {
  if (!fetchedFeed) return;
  
  this._updateActivities(fetchedFeed);
  this._updateMessages(fetchedFeed);

  // Init fetch loop
  setTimeout(this._fetchFeed.bind(this), this.config.fetchInterval);

};
```