<commit_before>import * as types from "constants/action_types";
import lbry from "lbry";
import {
  selectUpdateUrl,
  selectUpgradeDownloadPath,
  selectUpgradeDownloadItem,
  selectUpgradeFilename,
  selectPageTitle,
  selectCurrentPage,
  selectCurrentParams,
} from "selectors/app";
import { doSearch } from "actions/search";
import { doFetchDaemonSettings } from "actions/settings";
import { doAuthenticate } from "actions/user";
import { doFileList } from "actions/file_info";

const { remote, ipcRenderer, shell } = require("electron");
const path = require("path");
const { download } = remote.require("electron-dl");
const fs = remote.require("fs");
const { lbrySettings: config } = require("../../../app/package.json");

const queryStringFromParams = params => {
  return Object.keys(params).map(key => `${key}=${params[key]}`).join("&");
};

export function doNavigate(path, params = {}) {
  return function(dispatch, getState) {
    let url = path;
    if (params) url = `${url}?${queryStringFromParams(params)}`;

    dispatch(doChangePath(url));

    const state = getState();
    const pageTitle = selectPageTitle(state);
    dispatch(doHistoryPush({ params }, pageTitle, url));
  };
}

export function doChangePath(path, options = {}) {
  return function(dispatch, getState) {
    dispatch({
      type: types.CHANGE_PATH,
      data: {
        path,
      },
    });

    const state = getState();
    const pageTitle = selectPageTitle(state);
    const scrollY = options.scrollY;

    window.document.title = pageTitle;

    if (scrollY) window.scrollTo(0, scrollY);
    else window.scrollTo(0, 0);

    const currentPage = selectCurrentPage(state);
    if (currentPage === "search") {
      const params = selectCurrentParams(state);
      dispatch(doSearch(params.query));<commit_msg>Use toQueryString from util/query_params in app actions<commit_after>import * as types from "constants/action_types";
import lbry from "lbry";
import {
  selectUpdateUrl,
  selectUpgradeDownloadPath,
  selectUpgradeDownloadItem,
  selectUpgradeFilename,
  selectPageTitle,
  selectCurrentPage,
  selectCurrentParams,
} from "selectors/app";
import { doSearch } from "actions/search";
import { doFetchDaemonSettings } from "actions/settings";
import { doAuthenticate } from "actions/user";
import { doFileList } from "actions/file_info";
import { toQueryString } from "util/query_params";

const { remote, ipcRenderer, shell } = require("electron");
const path = require("path");
const { download } = remote.require("electron-dl");
const fs = remote.require("fs");
const { lbrySettings: config } = require("../../../app/package.json");

export function doNavigate(path, params = {}) {
  return function(dispatch, getState) {
    let url = path;
    if (params) url = `${url}?${toQueryString(params)}`;

    dispatch(doChangePath(url));

    const state = getState();
    const pageTitle = selectPageTitle(state);
    dispatch(doHistoryPush({ params }, pageTitle, url));
  };
}

export function doChangePath(path, options = {}) {
  return function(dispatch, getState) {
    dispatch({
      type: types.CHANGE_PATH,
      data: {
        path,
      },
    });

    const state = getState();
    const pageTitle = selectPageTitle(state);
    const scrollY = options.scrollY;

    window.document.title = pageTitle;

    if (scrollY) window.scrollTo(0, scrollY);
    else window.scrollTo(0, 0);

    const currentPage = selectCurrentPage(state);
    if (currentPage === "search") {
      const params = selectCurrentParams(state);
      dispatch(doSearch(params.query));
{'fraction_non_alphanumeric': 0.13805656678801456, 'fraction_numerical': 0.0016802016241949033, 'mean_word_length': 4.268436578171092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4513585', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1049, 'n_words': 251}