<commit_before>import goBackHistory from '@shopgate/pwa-common/actions/history/goBackHistory';
import { CHECKOUT_PATH } from '@shopgate/pwa-common/constants/RoutePaths';
import {
  routeDidEnter,
  routeDidLeave,
} from '@shopgate/pwa-common/streams/history';
import enableNavigator from 'Components/Navigator/actions/enableNavigator';
import disableNavigator from 'Components/Navigator/actions/disableNavigator';
/**
 * Checkout (dummy) page subscriptions.
 * @param {Function} subscribe The subscribe function.
 */
export default function checkout(subscribe) {
  const checkoutDidEnter$ = routeDidEnter(CHECKOUT_PATH);
  const checkoutDidLeave$ = routeDidLeave(CHECKOUT_PATH);

  let lockedUserTrigger;

  subscribe(checkoutDidEnter$, ({ dispatch }) => {
    dispatch(disableNavigator());
    // 20 seconds trigger. If user is locked on this page for 20 seconds, go back no matter what.
    lockedUserTrigger = setTimeout(() => {
      dispatch(goBackHistory());
    }, 20000);
  });
  subscribe(checkoutDidLeave$, ({ dispatch }) => {
    clearTimeout(lockedUserTrigger);
    dispatch(enableNavigator());
  });
}<commit_msg>PWA-486 - checkout timeout as a constant<commit_after>import goBackHistory from '@shopgate/pwa-common/actions/history/goBackHistory';
import { CHECKOUT_PATH } from '@shopgate/pwa-common/constants/RoutePaths';
import { FETCH_CHECKOUT_URL_TIMEOUT } from '@shopgate/pwa-common-commerce/checkout/constants';
import {
  routeDidEnter,
  routeDidLeave,
} from '@shopgate/pwa-common/streams/history';
import enableNavigator from 'Components/Navigator/actions/enableNavigator';
import disableNavigator from 'Components/Navigator/actions/disableNavigator';
/**
 * Checkout (dummy) page subscriptions.
 * @param {Function} subscribe The subscribe function.
 */
export default function checkout(subscribe) {
  const checkoutDidEnter$ = routeDidEnter(CHECKOUT_PATH);
  const checkoutDidLeave$ = routeDidLeave(CHECKOUT_PATH);

  let lockedUserTrigger;

  subscribe(checkoutDidEnter$, ({ dispatch }) => {
    dispatch(disableNavigator());
    // If user is locked on this page for too long, go back no matter what.
    lockedUserTrigger = setTimeout(() => {
      dispatch(goBackHistory());
    }, FETCH_CHECKOUT_URL_TIMEOUT);
  });
  subscribe(checkoutDidLeave$, ({ dispatch }) => {
    clearTimeout(lockedUserTrigger);
    dispatch(enableNavigator());
  });
}
{'fraction_non_alphanumeric': 0.11883691529709228, 'fraction_numerical': 0.0050568900126422255, 'mean_word_length': 5.381720430107527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7296974', 'n_tokens_mistral': 688, 'n_tokens_neox': 664, 'n_words': 150}