@@ -5,7 +5,12 @@ import {settingsManager} from '../../../services/settings';
5
5
import { TracingLevelNumber } from '../../../types/api/query' ;
6
6
import type { QueryAction , QueryRequestParams , QuerySettings } from '../../../types/store/query' ;
7
7
import type { StreamDataChunk } from '../../../types/store/streaming' ;
8
- import { QUERIES_HISTORY_KEY } from '../../../utils/constants' ;
8
+ import { loadFromSessionStorage , saveToSessionStorage } from '../../../utils' ;
9
+ import {
10
+ QUERIES_HISTORY_KEY ,
11
+ QUERY_EDITOR_CURRENT_QUERY_KEY ,
12
+ QUERY_EDITOR_DIRTY_KEY ,
13
+ } from '../../../utils/constants' ;
9
14
import { isQueryErrorResponse } from '../../../utils/query' ;
10
15
import { isNumeric } from '../../../utils/utils' ;
11
16
import type { RootState } from '../../defaultStore' ;
@@ -29,9 +34,14 @@ const queriesHistoryInitial = settingsManager.readUserSettingsValue(
29
34
30
35
const sliceLimit = queriesHistoryInitial . length - MAXIMUM_QUERIES_IN_HISTORY ;
31
36
37
+ const rawQuery = loadFromSessionStorage ( QUERY_EDITOR_CURRENT_QUERY_KEY ) ;
38
+ const input = typeof rawQuery === 'string' ? rawQuery : '' ;
39
+
40
+ const isDirty = Boolean ( loadFromSessionStorage ( QUERY_EDITOR_DIRTY_KEY ) ) ;
41
+
32
42
const initialState : QueryState = {
33
- input : '' ,
34
- isDirty : false ,
43
+ input,
44
+ isDirty,
35
45
history : {
36
46
queries : queriesHistoryInitial
37
47
. slice ( sliceLimit < 0 ? 0 : sliceLimit )
@@ -50,9 +60,11 @@ const slice = createSlice({
50
60
reducers : {
51
61
changeUserInput : ( state , action : PayloadAction < { input : string } > ) => {
52
62
state . input = action . payload . input ;
63
+ saveToSessionStorage ( QUERY_EDITOR_CURRENT_QUERY_KEY , action . payload . input ) ;
53
64
} ,
54
65
setIsDirty : ( state , action : PayloadAction < boolean > ) => {
55
66
state . isDirty = action . payload ;
67
+ saveToSessionStorage ( QUERY_EDITOR_DIRTY_KEY , action . payload ) ;
56
68
} ,
57
69
setQueryResult : ( state , action : PayloadAction < QueryResult | undefined > ) => {
58
70
state . result = action . payload ;
0 commit comments