fix: return query for app mode (#1954)

This commit is contained in:
Yury Molodov 2021-12-16 12:44:46 +03:00 committed by GitHub
parent a3adf24527
commit eaf82fe411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,5 @@
import qs from "qs";
import get from "lodash.get";
import {getAppModeEnable} from "./app-mode";
const stateToUrlParams = {
"time.duration": "range_input",
@ -9,8 +8,6 @@ const stateToUrlParams = {
"displayType": "tab"
};
const appModeEnable = getAppModeEnable();
// TODO need function for detect types.
// const decoder = (value: string) => {
// This function does not parse dates
@ -34,16 +31,12 @@ const appModeEnable = getAppModeEnable();
export const setQueryStringWithoutPageReload = (qsValue: string): void => {
const w = window;
if (w) {
const newurl = `${w.location.protocol}//${w.location.host}${w.location.pathname}${qsValue ? "?" : ""}${qsValue}`;
const newurl = `${w.location.protocol}//${w.location.host}${w.location.pathname}?${qsValue}`;
w.history.pushState({ path: newurl }, "", newurl);
}
};
export const setQueryStringValue = (newValue: Record<string, unknown>): void => {
if (appModeEnable) {
setQueryStringWithoutPageReload("");
return;
}
const queryMap = new Map(Object.entries(stateToUrlParams));
const query = get(newValue, "query", "") as string[];
const newQsValue: string[] = [];