<commit_before>import throttle from 'common/throttle';
import { json, form } from 'common/xhr';
import SwissCtrl from './ctrl';
import { isOutcome } from './util';

// when the tournament no longer exists
const onFail = () => lichess.reload();

const join = (ctrl: SwissCtrl, password?: string) =>
  json(`/swiss/${ctrl.data.id}/join`, {
    method: 'post',
    body: password
      ? form({
          password: password,
        })
      : undefined,
  }).catch(onFail);

const withdraw = (ctrl: SwissCtrl) => json(`/swiss/${ctrl.data.id}/withdraw`, { method: 'post' }).catch(onFail);

const loadPage = (ctrl: SwissCtrl, p: number, callback?: () => void) =>
  json(`/swiss/${ctrl.data.id}/standing/${p}`).then(data => {
    ctrl.loadPage(data);
    callback?.();
    ctrl.redraw();
  });

const loadPageOf = (ctrl: SwissCtrl, userId: string): Promise<any> => json(`/swiss/${ctrl.data.id}/page-of/${userId}`);

const reload = (ctrl: SwissCtrl) =>
  json(`/swiss/${ctrl.data.id}?page=${ctrl.focusOnMe ? '' : ctrl.page}&playerInfo=${ctrl.playerInfoId || ''}`).then(
    data => {
      ctrl.reload(data);<commit_msg>hotfix swiss join client<commit_after>import throttle from 'common/throttle';
import { json } from 'common/xhr';
import SwissCtrl from './ctrl';
import { isOutcome } from './util';

// when the tournament no longer exists
const onFail = () => lichess.reload();

const join = (ctrl: SwissCtrl, password?: string) =>
  json(`/swiss/${ctrl.data.id}/join`, {
    method: 'post',
    body: JSON.stringify({
      password: password || '',
    }),
    headers: { 'Content-Type': 'application/json' },
  }).catch(onFail);

const withdraw = (ctrl: SwissCtrl) => json(`/swiss/${ctrl.data.id}/withdraw`, { method: 'post' }).catch(onFail);

const loadPage = (ctrl: SwissCtrl, p: number, callback?: () => void) =>
  json(`/swiss/${ctrl.data.id}/standing/${p}`).then(data => {
    ctrl.loadPage(data);
    callback?.();
    ctrl.redraw();
  });

const loadPageOf = (ctrl: SwissCtrl, userId: string): Promise<any> => json(`/swiss/${ctrl.data.id}/page-of/${userId}`);

const reload = (ctrl: SwissCtrl) =>
  json(`/swiss/${ctrl.data.id}?page=${ctrl.focusOnMe ? '' : ctrl.page}&playerInfo=${ctrl.playerInfoId || ''}`).then(
    data => {
      ctrl.reload(data);
{'fraction_non_alphanumeric': 0.21381142098273573, 'fraction_numerical': 0.0, 'mean_word_length': 3.8812095032397407, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '7617772', 'n_tokens_mistral': 748, 'n_tokens_neox': 761, 'n_words': 160}