<commit_before>'use strict';

function MenuController($location, $scope, AuthenticationService, UISessionService, UserSessionService, AnalyticsService, ListsService) {

  $scope.isAdmin = function isAdmin() {
    return UserSessionService.getUserType() === 0;
  };

  $scope.getActiveOwnerName = function(){
    var activeUUID = UISessionService.getActiveUUID();
    var ownerName;
    if (activeUUID === UserSessionService.getUserUUID()){
      ownerName = UserSessionService.getEmail();
    }else{
      angular.forEach($scope.collectives, function(collective, uuid){
        if (activeUUID === uuid){
          ownerName = collective[0];
        }
      })
    }
    var maximumOwnerNameLength = 20;
    if (ownerName.length > maximumOwnerNameLength){
      return ownerName.substring(0, maximumOwnerNameLength) + '...';
    }
    return ownerName;
  }

  $scope.getFeatureClass = function getFeatureClass(feature) {
    if (UISessionService.getCurrentFeatureName() === feature) {
      return 'active';
    }
  };

  $scope.gotoFeature = function gotoFeature(feature) {
    if (UISessionService.getCurrentFeatureName() !== feature) {
      var state = UISessionService.getFeatureState(feature);
      if (!state && feature === 'notes'){
        state = 'notes/home';
      }
      UISessionService.changeFeature(feature, undefined, state);
      AnalyticsService.visit(feature);
    }
    $scope.toggleMenu();
  };

  // LISTS

  $scope.lists = ListsService.getLists(UISessionService.getActiveUUID());

  $scope.listsVisible = true;
  $scope.getListClass = function getListClass(list) {
    if (UISessionService.getCurrentFeatureName() === 'list' &&
        UISessionService.getFeatureData('list') === list) {
      return 'active';
    }
  };

  $scope.gotoList = function(list){
    if (UISessionService.getCurrentFeatureName() !== 'list' ||
        UISessionService.getFeatureState('list') !== list) {
      UISessionService.changeFeature('list', list);
      AnalyticsService.visit('list');
    }
    $scope.toggleMenu();
  }

  $scope.toggleLists = function(){
    $scope.listsVisible = !$scope.listsVisible;
    if ($scope.refreshScroller) $scope.refreshScroller();
  }

  $scope.getListTitleText = function(list){
    var maximumListNameLength = 35;
    if (list.title.length > maximumListNameLength){
      return list.title.substring(0, maximumListNameLength-2) + '...';
    }
    return list.title;
  }
}

MenuController.$inject = ['$location', '$scope', 'AuthenticationService', 'UISessionService', 'UserSessionService', 'AnalyticsService', 'ListsService'];
angular.module('em.app').controller('MenuController', MenuController);
<commit_msg>Refreshing scroller when lists are loaded<commit_after>'use strict';

function MenuController($location, $scope, AuthenticationService, UISessionService, UserSessionService, AnalyticsService, ListsService) {

  $scope.isAdmin = function isAdmin() {
    return UserSessionService.getUserType() === 0;
  };

  $scope.getActiveOwnerName = function(){
    var activeUUID = UISessionService.getActiveUUID();
    var ownerName;
    if (activeUUID === UserSessionService.getUserUUID()){
      ownerName = UserSessionService.getEmail();
    }else{
      angular.forEach($scope.collectives, function(collective, uuid){
        if (activeUUID === uuid){
          ownerName = collective[0];
        }
      })
    }
    var maximumOwnerNameLength = 20;
    if (ownerName.length > maximumOwnerNameLength){
      return ownerName.substring(0, maximumOwnerNameLength) + '...';
    }
    return ownerName;
  }

  $scope.getFeatureClass = function getFeatureClass(feature) {
    if (UISessionService.getCurrentFeatureName() === feature) {
      return 'active';
    }
  };

  $scope.gotoFeature = function gotoFeature(feature) {
    if (UISessionService.getCurrentFeatureName() !== feature) {
      var state = UISessionService.getFeatureState(feature);
      if (!state && feature === 'notes'){
        state = 'notes/home';
      }
      UISessionService.changeFeature(feature, undefined, state);
      AnalyticsService.visit(feature);
    }
    $scope.toggleMenu();
  };

  // LISTS

  $scope.lists = ListsService.getLists(UISessionService.getActiveUUID());

  $scope.$watch('lists.length', function(/*newValue, oldValue*/) {
    if ($scope.refreshScroller) $scope.refreshScroller();
  });

  $scope.listsVisible = true;
  $scope.getListClass = function getListClass(list) {
    if (UISessionService.getCurrentFeatureName() === 'list' &&
        UISessionService.getFeatureData('list') === list) {
      return 'active';
    }
  };

  $scope.gotoList = function(list){
    if (UISessionService.getCurrentFeatureName() !== 'list' ||
        UISessionService.getFeatureState('list') !== list) {
      UISessionService.changeFeature('list', list);
      AnalyticsService.visit('list');
    }
    $scope.toggleMenu();
  }

  $scope.toggleLists = function(){
    $scope.listsVisible = !$scope.listsVisible;
    if ($scope.refreshScroller) $scope.refreshScroller();
  }

  $scope.getListTitleText = function(list){
    var maximumListNameLength = 35;
    if (list.title.length > maximumListNameLength){
      return list.title.substring(0, maximumListNameLength-2) + '...';
    }
    return list.title;
  }
}

MenuController.$inject = ['$location', '$scope', 'AuthenticationService', 'UISessionService', 'UserSessionService', 'AnalyticsService', 'ListsService'];
angular.module('em.app').controller('MenuController', MenuController);

{'fraction_non_alphanumeric': 0.14108187134502925, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 3.9085201793721973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5526547', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1596, 'n_words': 275}