<commit_before>var notify = module.exports = function (message) {
  notify.cancel();
  msg = message;
  notify.start();

  if (!handlesClick) {
    handlesClick = true;
    document.body.addEventListener('click', notify.cancel);
  }
};

var MESSAGE_DURATION = 500;
var DEFAULT_DURATION = 700;

var tid = null;
var deflt = 'Meishengo';
var active = false;
var msg = null;
var handlesClick = false;

notify.cancel = function () {
  active = false;
  msg = null;
  notify.showDefault();
  if (tid !== null) clearTimeout(tid);
};

notify.start = function () {
  active = true;
  notify.showMessage();
  tid = setTimeout(notify.showDefault, MESSAGE_DURATION);
};

notify.setTitle = function (text) {
  document.querySelector('head title').firstChild.data = text;
};


notify.showDefault = function () {
  if (!active) return;
  notify.setTitle(deflt);
  tid = setTimeout(notify.showMessage, DEFAULT_DURATION);
};

notify.showMessage = function () {
  if (!active) return;
  if (!!msg) notify.setTitle(msg);
  tid = setTimeout(notify.showDefault, MESSAGE_DURATION);
};

<commit_msg>fix notification interruption<commit_after>var _ = require('underscore');

var notify = module.exports = function (message) {
  if (tid !== null) clearTimeout(tid);
  msg = message;
  notify.start();

  if (!handlesClick) {
    handlesClick = true;
    document.body.addEventListener('click', notify.cancel);
  }
};

var MESSAGE_DURATION = 500;
var DEFAULT_DURATION = 700;

var tid = null;
var deflt = 'Meishengo';
var active = false;
var msg = null;
var handlesClick = false;

notify.cancel = function () {
  active = false;
  msg = null;
  _.defer(notify.showDefault);
  if (tid !== null) clearTimeout(tid);
};

notify.start = function () {
  active = true;
  notify.showMessage();
  tid = setTimeout(notify.showDefault, MESSAGE_DURATION);
};

notify.setTitle = function (text) {
  document.querySelector('head title').firstChild.data = text;
};


notify.showDefault = function () {
  if (!active) return;
  notify.setTitle(deflt);
  tid = setTimeout(notify.showMessage, DEFAULT_DURATION);
};

notify.showMessage = function () {
  if (!active) return;
  if (!!msg) notify.setTitle(msg);
  tid = setTimeout(notify.showDefault, MESSAGE_DURATION);
};


{'fraction_non_alphanumeric': 0.14593623709025594, 'fraction_numerical': 0.005388414907947912, 'mean_word_length': 4.407766990291262, 'pattern_counts': {'":': 0, '<': 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': '3583746', 'n_tokens_mistral': 745, 'n_tokens_neox': 735, 'n_words': 169}