From c6d592728161f88fe17a183750fb01bdf78538f6 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Tue, 30 Nov 2021 01:58:27 +0300 Subject: [PATCH] feat: remove save the last query to local storage (#1853) --- .../vmui/src/components/Home/Configurator/useFetchQuery.ts | 2 -- app/vmui/packages/vmui/src/state/common/reducer.ts | 2 +- app/vmui/packages/vmui/src/utils/storage.ts | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/vmui/packages/vmui/src/components/Home/Configurator/useFetchQuery.ts b/app/vmui/packages/vmui/src/components/Home/Configurator/useFetchQuery.ts index 72e7e64b8b..09c1913c3c 100644 --- a/app/vmui/packages/vmui/src/components/Home/Configurator/useFetchQuery.ts +++ b/app/vmui/packages/vmui/src/components/Home/Configurator/useFetchQuery.ts @@ -2,7 +2,6 @@ import {useEffect, useMemo, useState} from "react"; import {getQueryRangeUrl, getQueryUrl} from "../../../api/query-range"; import {useAppState} from "../../../state/common/StateContext"; import {InstantMetricResult, MetricResult} from "../../../api/types"; -import {saveToStorage} from "../../../utils/storage"; import {isValidHttpUrl} from "../../../utils/url"; import {useAuthState} from "../../../state/auth/AuthStateContext"; import {TimeParams} from "../../../types"; @@ -56,7 +55,6 @@ export const useFetchQuery = (): { try { const response = await fetch(fetchUrl, { headers }); if (response.ok) { - saveToStorage("LAST_QUERY", query); const resp = await response.json(); setError(undefined); displayType === "chart" ? setGraphData(resp.data.result) : setLiveData(resp.data.result); diff --git a/app/vmui/packages/vmui/src/state/common/reducer.ts b/app/vmui/packages/vmui/src/state/common/reducer.ts index 3b409b78ed..a0b3ac2502 100644 --- a/app/vmui/packages/vmui/src/state/common/reducer.ts +++ b/app/vmui/packages/vmui/src/state/common/reducer.ts @@ -46,7 +46,7 @@ export type Action = const duration = getQueryStringValue("g0.range_input", "1h") as string; const endInput = formatDateToLocal(getQueryStringValue("g0.end_input", getDateNowUTC()) as Date); -const query = getQueryStringValue("g0.expr", getFromStorage("LAST_QUERY") as string || "\n") as string; +const query = getQueryStringValue("g0.expr", "") as string; export const initialState: AppState = { serverUrl: getDefaultServer(), diff --git a/app/vmui/packages/vmui/src/utils/storage.ts b/app/vmui/packages/vmui/src/utils/storage.ts index 6346f25e12..2a79c59995 100644 --- a/app/vmui/packages/vmui/src/utils/storage.ts +++ b/app/vmui/packages/vmui/src/utils/storage.ts @@ -1,5 +1,4 @@ -export type StorageKeys = "LAST_QUERY" - | "BASIC_AUTH_DATA" +export type StorageKeys = "BASIC_AUTH_DATA" | "BEARER_AUTH_DATA" | "AUTH_TYPE" | "AUTOCOMPLETE"