<commit_before>'use strict';

angular.module('myApp.home', ['ngRoute'])

	.config(['$routeProvider', function($routeProvider) {
		$routeProvider.when('/home', {
			templateUrl: 'home/home.html',
			controller: 'HomeCtrl'
		});
	}])

	.controller('HomeCtrl', ['$scope', '$http', '$log', '$uibModal', function ($scope, $http, $log, $uibModal) {
		$log.debug('registered HomeCtrl');

		function updateMessages() {
			$log.debug('updating messages');
			$http.get("https://eg5f5pcd8i.execute-api.us-east-1.amazonaws.com/prod/cudas_getMessages").then(function (response) {
				$scope.messages = response.data.Items;
			});
		}

		updateMessages();

		$scope.open = function () {
			$log.debug("Entered modal open function");

			var modalInstance = $uibModal.open({
				animation: true,
				templateUrl: 'messageModalContent',
				controller: 'ModalInstanceCtrl',
				size: "md"
			});

			modalInstance.result.then(function (selectedItem) {
				$scope.selected = selectedItem;
			}, function () {
				$log.info('Modal dismissed at: ' + new Date());
			});
		};
	}])

	.controller('ModalInstanceCtrl', ['$scope', '$uibModalInstance', '$log', '$http', function ($scope, $uibModalInstance, $log, $http) {

		$scope.post = function (message) {
			$log.debug("Posting message=" + JSON.stringify(message));
			
			$http({
				method: "POST",
				url: 'https://eg5f5pcd8i.execute-api.us-east-1.amazonaws.com/prod/cudas_postMessage',
				data: {"message": message},
				headers: {}
			}).then(function (response) {
				$log.debug("response=" + JSON.stringify(response));
			});

			$uibModalInstance.close();
		};<commit_msg>[AUTH] message list now updates after message post<commit_after>'use strict';

angular.module('myApp.home', ['ngRoute'])

	.config(['$routeProvider', function($routeProvider) {
		$routeProvider.when('/home', {
			templateUrl: 'home/home.html',
			controller: 'HomeCtrl'
		});
	}])

	.controller('HomeCtrl', ['$scope', '$http', '$log', '$uibModal', '$rootScope', function ($scope, $http, $log, $uibModal, $rootScope) {
		$log.debug('registered HomeCtrl');

		function updateMessages() {
			$log.debug('updating messages');
			$http.get("https://eg5f5pcd8i.execute-api.us-east-1.amazonaws.com/prod/cudas_getMessages").then(function (response) {
				$scope.messages = response.data.Items;
			});
		}

		updateMessages();

		$rootScope.$on('messagePosted', function() {
			updateMessages();
		});

		$scope.open = function () {
			$log.debug("Entered modal open function");

			var modalInstance = $uibModal.open({
				animation: true,
				templateUrl: 'messageModalContent',
				controller: 'ModalInstanceCtrl',
				size: "md"
			});

			modalInstance.result.then(function () {
				$log.info('Message post sent at : ' + new Date());
			}, function () {
				$log.info('Modal dismissed at: ' + new Date());
			});
		};
	}])

	.controller('ModalInstanceCtrl', ['$scope', '$uibModalInstance', '$log', '$http', '$rootScope', function ($scope, $uibModalInstance, $log, $http, $rootScope) {

		$scope.post = function (message) {
			$log.debug("Posting message=" + JSON.stringify(message));
			
			$http({
				method: "POST",
				url: 'https://eg5f5pcd8i.execute-api.us-east-1.amazonaws.com/prod/cudas_postMessage',
				data: {"message": message},
				headers: {}
			}).then(function (response) {
				$log.debug("response=" + JSON.stringify(response));
				$rootScope.$broadcast('messagePosted');
			});

			$uibModalInstance.close();
		};
{'fraction_non_alphanumeric': 0.1967451322290032, 'fraction_numerical': 0.004649811101424005, 'mean_word_length': 4.231003039513678, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '571321', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1120, 'n_words': 196}