if (Meteor.isCordova) {
	document.addEventListener('pause', () => {
		UserPresence.setAway();
		readMessage.disable();
		Meteor.disconnect();
	}, true);

	document.addEventListener('resume', () => {
		Meteor.reconnect();
		UserPresence.setOnline();
		readMessage.enable();
	}, true);
}

/* globals UserPresence, readMessage */

var timer = undefined;
if (Meteor.isCordova) {
	document.addEventListener('pause', () => {
		UserPresence.setAway();
		readMessage.disable();

		//Only disconnect after one minute of being in the background
		timer = setTimeout(() => {
			Meteor.disconnect();
			timer = undefined;
		}, 60000);
	}, true);

	document.addEventListener('resume', () => {
		if (!_.isUndefined(timer)) {
			clearTimeout(timer);
		}

		Meteor.reconnect();
		UserPresence.setOnline();
		readMessage.enable();
	}, true);
}

Add the timer for disconnecting, one minute after going in the background it'll disconnect
Add the timer for disconnecting, one minute after going in the background it'll disconnect
