<commit_before>app.directive('messageLogScroll', function ($timeout, $rootScope, bunkerData, animationControl) {
	return {
		scope: {
			roomId: '@',
			onScrollTop: '&'
		},
		link: function ($scope, elem) {
			var el = elem[0];
			var tolerance = 31;
			var clearMessageCounter = 0;

			function atBottomOfPage() {
				return el.scrollTop + el.clientHeight + tolerance >= el.scrollHeight;
			}

			$rootScope.$on('bunkerMessaged', function (evt, message) {

				if (atBottomOfPage() || message.author._id == bunkerData.user._id) {
					// Check for images
					var image = angular.element('#' + message._id).find('img');
					if (image.length) {
						// If we have an image, wait for it to load before scrolling
						image.load(function () {
							scroll(250);
						});
					} else {
						// Otherwise scroll immediately
						scroll();
					}

					// if the user is only watching new messages, trim the message log
					clearMessageCounter++;
					if (clearMessageCounter > 5) {
						bunkerData.clearOldMessages($scope.roomId);
						clearMessageCounter = 0;
					}
				} else {
					clearMessageCounter = 0;
				}
			});

			// Watch scrolling to top, execute given function
			angular.element(el).bind('scroll', _.throttle(function () {
				// We're at the top
				if (el.scrollTop == 0 && angular.isFunction($scope.onScrollTop)) {
					var originalHeight = el.scrollHeight;
					$scope.onScrollTop()
						.then(() => $timeout(() => {
							el.scrollTop = el.scrollHeight - originalHeight
						}));
				}
			}, 50));
<commit_msg>wait longer for image scroll<commit_after>app.directive('messageLogScroll', function ($timeout, $rootScope, bunkerData, animationControl) {
	return {
		scope: {
			roomId: '@',
			onScrollTop: '&'
		},
		link: function ($scope, elem) {
			var el = elem[0];
			var tolerance = 31;
			var clearMessageCounter = 0;

			function atBottomOfPage() {
				return el.scrollTop + el.clientHeight + tolerance >= el.scrollHeight;
			}

			$rootScope.$on('bunkerMessaged', function (evt, message) {

				if (atBottomOfPage() || message.author._id == bunkerData.user._id) {
					// Check for images
					var image = angular.element('#' + message._id).find('img');
					if (image.length) {
						// If we have an image, wait for it to load before scrolling
						image.load(function () {
							scroll(500);
						});
					} else {
						// Otherwise scroll immediately
						scroll();
					}

					// if the user is only watching new messages, trim the message log
					clearMessageCounter++;
					if (clearMessageCounter > 5) {
						bunkerData.clearOldMessages($scope.roomId);
						clearMessageCounter = 0;
					}
				} else {
					clearMessageCounter = 0;
				}
			});

			// Watch scrolling to top, execute given function
			angular.element(el).bind('scroll', _.throttle(function () {
				// We're at the top
				if (el.scrollTop == 0 && angular.isFunction($scope.onScrollTop)) {
					var originalHeight = el.scrollHeight;
					$scope.onScrollTop()
						.then(() => $timeout(() => {
							el.scrollTop = el.scrollHeight - originalHeight
						}));
				}
			}, 50));

{'fraction_non_alphanumeric': 0.13922010957138253, 'fraction_numerical': 0.00837898807605543, 'mean_word_length': 2.708482676224612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6068971', 'n_tokens_mistral': 1271, 'n_tokens_neox': 926, 'n_words': 234}