<commit_before>'use strict';

angular.module('chat.details', ['ngRoute','ngAnimate', 'ngSanitize'])

.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/details/:uid/:id', {
    templateUrl: 'details/details.html',
    controller: 'DetailsCtrl'
  });
}])

.controller('DetailsCtrl', ['$scope', '$routeParams', 'DataService', 'UserChatService',
  function($scope, $routeParams, DataService, UserChatService) {
    $scope.pageClass = 'animate-details';
    $scope.chatId = parseInt($routeParams.id, 10);
    $scope.userId = parseInt($routeParams.uid, 10);
    if(!isNaN($scope.chatId) && !isNaN($scope.userId)) {
      $scope.messages = [];
      $scope.newMessage = '';
      $scope.pageTitle = ['.'];

      $scope.insertMessage = function(msg) {        
        if(!msg) {
          var msgId = $scope.messages[$scope.messages.length-1].msg_id + 1;
          msg = {"msg_id":msgId, "sender_id":$scope.userId, "text":$scope.newMessage, "datetime":"", "last":true};
        }
        var lastMsg = $scope.messages[$scope.messages.length-1];
        if(lastMsg && lastMsg.sender_id == msg.sender_id) {
          $scope.messages[$scope.messages.length-1].last = false;
        }

        // get the participant name and append to msg
        if($scope.participants) {
          var i = $scope.participants.length - 1;
          do {
            var p = $scope.participants[i];
            if(p.id === msg.sender_id) {
              msg.senderFirst = p.firstName;
              msg.senderLast = p.lastName;
              break;<commit_msg>add message to stored chat in UserChatService<commit_after>'use strict';

angular.module('chat.details', ['ngRoute','ngAnimate', 'ngSanitize'])

.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/details/:uid/:id', {
    templateUrl: 'details/details.html',
    controller: 'DetailsCtrl'
  });
}])

.controller('DetailsCtrl', ['$scope', '$routeParams', 'DataService', 'UserChatService',
  function($scope, $routeParams, DataService, UserChatService) {
    $scope.pageClass = 'animate-details';
    $scope.chatId = parseInt($routeParams.id, 10);
    $scope.userId = parseInt($routeParams.uid, 10);
    if(!isNaN($scope.chatId) && !isNaN($scope.userId)) {
      $scope.messages = [];
      $scope.newMessage = '';
      $scope.pageTitle = ['.'];

      $scope.insertMessage = function(msg) {
        if(!msg) { // this is a new message
          var msgId = $scope.messages[$scope.messages.length-1].msg_id + 1;
          msg = {"msg_id":msgId, "sender_id":$scope.userId, "text":$scope.newMessage, "datetime":"", "last":true};
          UserChatService.addMessage($scope.chatId, msg);
        }
        var lastMsg = $scope.messages[$scope.messages.length-1];
        if(lastMsg && lastMsg.sender_id == msg.sender_id) {
          $scope.messages[$scope.messages.length-1].last = false;
        }

        // get the participant name and append to msg
        if($scope.participants) {
          var i = $scope.participants.length - 1;
          do {
            var p = $scope.participants[i];
            if(p.id === msg.sender_id) {
              msg.senderFirst = p.firstName;
              msg.senderLast = p.lastName;
              break;
{'fraction_non_alphanumeric': 0.17002167853824712, 'fraction_numerical': 0.005574481263549086, 'mean_word_length': 2.840665873959572, 'pattern_counts': {'":': 10, '<': 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': '3911218', 'n_tokens_mistral': 1006, 'n_tokens_neox': 994, 'n_words': 170}