<commit_before>import {
  GET,
} from '../../app/utils/http';
import $ from 'jquery';
import cleanHtml from '../../app/utils/cleanHtml';
import {
  setChromeLocalStore,
  getChromeLocalStore,
} from '../../app/utils/settings';

import postHelper from '../../app/utils/postHelper';
import getSubscribedThreads from './getSubscribedThreads';

const REQUEST_TIMEOUT = 500;
const UPDATE_TIMEOUT = 60000 * 2; /* 2 min */

function getAllLastPost(threads, cb) {
  if (threads.length > 0) {
    const {
      id,
      lastPage,
      title,
    } = threads.shift();

    GET(`https://vozforums.com/showthread.php?t=${id}&page=${lastPage}`).then((html) => { // eslint-disable-line new-cap
      const postInfo = postHelper($(cleanHtml(html, ['images'])));
      const latestPost = Object.assign({
        title,
        page: lastPage,
      }, postInfo.getLatestPost() /* postNum, id */);
      getChromeLocalStore(['followThreads'])
        .then(({ followThreads }) => {
          setChromeLocalStore({
            followThreads: {
              ...followThreads,
              [id]: latestPost,
            },
          });
        });
      setTimeout(getAllLastPost.bind(null, threads, cb), REQUEST_TIMEOUT);
    });
  } else {
    cb();
  }
}

function validateSubscription(threads) {
  getChromeLocalStore(['followThreads'])
    .then(({ followThreads }) => {
      const validList = threads.map(t => t.id);
      const checkedMap = Object.keys(followThreads)
        .reduce((map, id) => {
          if (validList.indexOf(id) > -1) map[id] = followThreads[id];
          return map;
        }, {});
      setChromeLocalStore({
        followThreads: checkedMap,
      });
    });
  return threads;
}

function main() {<commit_msg>fix error break follow thread<commit_after>import {
  GET,
} from '../../app/utils/http';
import $ from 'jquery';
import cleanHtml from '../../app/utils/cleanHtml';
import {
  setChromeLocalStore,
  getChromeLocalStore,
} from '../../app/utils/settings';

import postHelper from '../../app/utils/postHelper';
import getSubscribedThreads from './getSubscribedThreads';

const REQUEST_TIMEOUT = 500;
const UPDATE_TIMEOUT = 60000 * 2; /* 2 min */

function getAllLastPost(threads, cb) {
  if (threads.length > 0) {
    const {
      id,
      lastPage,
      title,
    } = threads.shift();

    GET(`https://vozforums.com/showthread.php?t=${id}&page=${lastPage}`).then((html) => { // eslint-disable-line new-cap
      try {
        const postInfo = postHelper($(cleanHtml(html, ['images'])));
        const latestPost = Object.assign({
          title,
          page: lastPage,
        }, postInfo.getLatestPost() /* postNum, id */);
        getChromeLocalStore(['followThreads'])
          .then(({ followThreads }) => {
            setChromeLocalStore({
              followThreads: {
                ...followThreads,
                [id]: latestPost,
              },
            });
          });
      } catch(e) {
        console.error(e);
      }
      setTimeout(getAllLastPost.bind(null, threads, cb), REQUEST_TIMEOUT);
    });
  } else {
    cb();
  }
}

function validateSubscription(threads) {
  getChromeLocalStore(['followThreads'])
    .then(({ followThreads }) => {
      const validList = threads.map(t => t.id);
      const checkedMap = Object.keys(followThreads)
        .reduce((map, id) => {
          if (validList.indexOf(id) > -1) map[id] = followThreads[id];
          return map;
        }, {});
      setChromeLocalStore({
        followThreads: checkedMap,
      });
    });
  return threads;
}

function main() {
{'fraction_non_alphanumeric': 0.16120906801007556, 'fraction_numerical': 0.006717044500419815, 'mean_word_length': 2.4200956937799045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 2, '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': '5979349', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1099, 'n_words': 211}