|
1 | 1 | // Libraries |
2 | | -import React, {FC, lazy, Suspense, useContext} from 'react' |
| 2 | +import React, {FC, lazy, Suspense, useContext, useEffect} from 'react' |
3 | 3 | import { |
4 | 4 | DraggableResizer, |
5 | 5 | Orientation, |
@@ -40,6 +40,7 @@ import {getWindowPeriodVariableFromVariables} from 'src/variables/utils/getWindo |
40 | 40 | // Constants |
41 | 41 | import {TIME_RANGE_START, TIME_RANGE_STOP} from 'src/variables/constants' |
42 | 42 | import {DEFAULT_TIME_RANGE} from 'src/shared/constants/timeRanges' |
| 43 | +import {useSessionStorage} from '../shared/utils' |
43 | 44 |
|
44 | 45 | const FluxMonacoEditor = lazy(() => |
45 | 46 | import('src/shared/components/FluxMonacoEditor') |
@@ -94,9 +95,26 @@ const ResultsPane: FC = () => { |
94 | 95 | const {basic, query} = useContext(QueryContext) |
95 | 96 | const {status, setStatus, setResult} = useContext(ResultsContext) |
96 | 97 |
|
97 | | - const [horizDragPosition, setHorizDragPosition] = useResizeState() |
98 | | - const [text, setText] = useQueryState() |
99 | | - const [timeRange, setTimeRange] = useRangeState() |
| 98 | + const [oldHorizDragPosition, setOldHorizDragPosition] = useResizeState() |
| 99 | + const [horizDragPosition, setHorizDragPosition] = useSessionStorage( |
| 100 | + 'dataExplorer.resize.horizontal', |
| 101 | + oldHorizDragPosition |
| 102 | + ) |
| 103 | + const [oldText, setOldText] = useQueryState() |
| 104 | + const [text, setText] = useSessionStorage('dataExplorer.query', oldText) |
| 105 | + const [oldTimeRange, setOldTimeRange] = useRangeState() |
| 106 | + const [timeRange, setTimeRange] = useSessionStorage( |
| 107 | + 'dataExplorer.range', |
| 108 | + oldTimeRange |
| 109 | + ) |
| 110 | + |
| 111 | + // migration to allow people to keep their last used settings |
| 112 | + // immediately after rollout |
| 113 | + useEffect(() => { |
| 114 | + setOldHorizDragPosition([0.2]) |
| 115 | + setOldText('') |
| 116 | + setOldTimeRange(DEFAULT_TIME_RANGE) |
| 117 | + }, []) |
100 | 118 |
|
101 | 119 | const download = () => { |
102 | 120 | event('CSV Download Initiated') |
|
0 commit comments