<commit_before>import throttle from 'common/throttle';

let timeout;
let booted = false;

export function start(container: HTMLElement) {

  const resize = throttle(500, () => {
    window.requestAnimationFrame(() => {
      const chat = container.querySelector('.mchat') as HTMLElement;
      const board = container.querySelector('.analyse__board') as HTMLElement;
      const side = container.querySelector('.analyse__side') as HTMLElement;
      if (!chat || !board || !side) return;
      const height = board.offsetHeight - side.offsetHeight;
      if (height) chat.style.height = `calc(${height}px - 2vmin)`;
      schedule();
    });
  });

  function schedule() {
    timeout && clearTimeout(timeout);
    timeout = setTimeout(resize, 1000);
  }

  resize();

  if (!booted) {
    booted = true;
    document.body.addEventListener('chessground.resize', resize);
    window.lichess.pubsub.on('analyse.grid-hack', resize);
  }
}
<commit_msg>apply grid hack more often<commit_after>import throttle from 'common/throttle';

let timeout;
let booted = false;

export function start(container: HTMLElement) {

  const resize = throttle(100, () => {
    window.requestAnimationFrame(() => {
      const chat = container.querySelector('.mchat') as HTMLElement;
      const board = container.querySelector('.analyse__board') as HTMLElement;
      const side = container.querySelector('.analyse__side') as HTMLElement;
      if (!chat || !board || !side) return;
      const height = board.offsetHeight - side.offsetHeight;
      if (height) chat.style.height = `calc(${height}px - 2vmin)`;
      schedule();
    });
  });

  function schedule() {
    timeout && clearTimeout(timeout);
    timeout = setTimeout(resize, 1000);
  }

  resize();

  if (!booted) {
    booted = true;
    document.body.addEventListener('chessground.resize', resize);
    window.lichess.pubsub.on('analyse.grid-hack', resize);
  }
}

{'fraction_non_alphanumeric': 0.14248297537978, 'fraction_numerical': 0.008381351492928235, 'mean_word_length': 3.6699266503667483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2614858', 'n_tokens_mistral': 595, 'n_tokens_neox': 572, 'n_words': 130}