<commit_before>window.ChannelList = Backbone.Collection.extend({
  model: Channel,
  
  initialize: function() {
    this.bind('activate', this.setActiveChannel);
  },
  
  url: function() {
    return '/' + Router.getUsername() + '/channels/';
  },
  
  setActiveChannel: function(channel) {
    if ( this.activeChannel && this.activeChannel.id !== channel.id ) {
      this.activeChannel.trigger('deactivate');
    }
    
    this.activeChannel = channel;
  }<commit_msg>When the Channels collection is reset, the active state should be remembered.<commit_after>window.ChannelList = Backbone.Collection.extend({
  model: Channel,
  
  initialize: function() {
    this.bind('activate', this.setActiveChannel);
    this.bind('reset', this.checkActiveChannel);
  },
  
  url: function() {
    return '/' + Router.getUsername() + '/channels/';
  },
  
  setActiveChannel: function(channel) {
    if ( this.activeChannelId && this.activeChannelId !== channel.id ) {
      this.get(this.activeChannelId).trigger('deactivate');
    }
    
    this.activeChannelId = channel.id;
  },
  
  checkActiveChannel: function() {
    if ( this.activeChannelId ) {
      var activeChannel = this.get(this.activeChannelId);
      
      activeChannel.trigger('activate', activeChannel);
    }
  }
{'fraction_non_alphanumeric': 0.141295862607338, 'fraction_numerical': 0.0, 'mean_word_length': 3.3904109589041096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4437971', 'n_tokens_mistral': 382, 'n_tokens_neox': 380, 'n_words': 66}