fix: return query for app mode (#1954)

This commit is contained in:
Yury Molodov 2021-12-16 12:44:46 +03:00 committed by Aliaksandr Valialkin
parent 5bd4e47a9e
commit 7d32ca9ed3
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

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[] = [];