<commit_before>var _IsLoggedIn = undefined;


function checkIfLoggedInAndTriggerEvent(notifyLoggedOutEveryTime){
	request({module:"user", type: "IsLoggedIn"}, function(res){

		if(_IsLoggedIn === undefined){
			$(document).trigger("InitialUserStatus", res.loggedIn);
		}

		if(res.loggedIn != _IsLoggedIn){
			_IsLoggedIn = res.loggedIn;
			$(document).trigger(_IsLoggedIn ? "logged_out_timer" : "logged_in_timer");

			if(!_IsLoggedIn && typeof(Notifier) === "function")
				new Notifier().show("You are not logged in!");
		} else if(notifyLoggedOutEveryTime && !_IsLoggedIn){
			new Notifier().show("You are not logged in!");
		}
	});
	
}

$(document).bind('request_error', function(){
	checkIfLoggedInAndTriggerEvent(true);
});

setInterval(checkIfLoggedInAndTriggerEvent, 10000);
checkIfLoggedInAndTriggerEvent();


$(document).bind('InitialUserStatus', function(e, arg){
	_IsLoggedIn = arg;
});

$(document).bind('LoggedIn', function(){
	_IsLoggedIn = true;
});

$(document).bind('LoggedOut', function(){
	_IsLoggedIn = false;
});

function isLoggedIn(){
	return _IsLoggedIn;
}<commit_msg>Fix indefinite event loop on connection error<commit_after>var _IsLoggedIn = undefined;

function checkIfLoggedInAndTriggerEvent(notifyLoggedOutEveryTime){
	request({module:"user", type: "IsLoggedIn"}, function(res){

		if(_IsLoggedIn === undefined){
			$(document).trigger("InitialUserStatus", res.loggedIn);
		}

		if(res.loggedIn != _IsLoggedIn){
			_IsLoggedIn = res.loggedIn;
			$(document).trigger(_IsLoggedIn ? "logged_out_timer" : "logged_in_timer");

			if(!_IsLoggedIn && typeof(Notifier) === "function")
				new Notifier().show("You are not logged in!");
		} else if(notifyLoggedOutEveryTime && !_IsLoggedIn){
			new Notifier().show("You are not logged in!");
		}
	});
	
}

var lastIsLoggedInErrorCheck = 0;
$(document).bind('request_error', function(){
	if(new Date().getTime() > lastIsLoggedInErrorCheck + 1000) //Only notify about login errors every sec
		checkIfLoggedInAndTriggerEvent(true);
	lastIsLoggedInErrorCheck = new Date().getTime();
});

setInterval(checkIfLoggedInAndTriggerEvent, 10000);
checkIfLoggedInAndTriggerEvent();


$(document).bind('InitialUserStatus', function(e, arg){
	_IsLoggedIn = arg;
});

$(document).bind('LoggedIn', function(){
	_IsLoggedIn = true;
});

$(document).bind('LoggedOut', function(){
	_IsLoggedIn = false;
});

function isLoggedIn(){
	return _IsLoggedIn;
}
{'fraction_non_alphanumeric': 0.15953469048608226, 'fraction_numerical': 0.0062318238471125885, 'mean_word_length': 6.525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1415776', 'n_tokens_mistral': 878, 'n_tokens_neox': 810, 'n_words': 145}