@@ -23,11 +23,11 @@ const spliceTabs = (tabs, index, updatedTab) => {
23
23
return [ ...before , ...updated , ...after ]
24
24
}
25
25
26
- const newTab = id => {
26
+ const newTab = ( id ) => {
27
27
return { ...tabTemplate , id, name : `Query ${ id } ` }
28
28
}
29
29
30
- const initTabState = storageNameSpace => {
30
+ const initTabState = ( storageNameSpace ) => {
31
31
if ( localStorage . getItem ( storageNameSpace ) ) {
32
32
const { version, ...storedState } = JSON . parse (
33
33
localStorage . getItem ( storageNameSpace )
@@ -42,9 +42,9 @@ const initTabState = storageNameSpace => {
42
42
tabs : [ newTab ( 1 ) ] ,
43
43
}
44
44
}
45
- const nextAvailableId = tabs => {
45
+ const nextAvailableId = ( tabs ) => {
46
46
let candidate = 0
47
- while ( tabs . some ( tab => tab . id === candidate ) ) {
47
+ while ( tabs . some ( ( tab ) => tab . id === candidate ) ) {
48
48
++ candidate
49
49
}
50
50
return candidate
@@ -98,13 +98,13 @@ const reducer = (state, action) => {
98
98
}
99
99
}
100
100
101
- const prepareForStorage = state => ( {
101
+ const prepareForStorage = ( state ) => ( {
102
102
version : VERSION ,
103
103
...state ,
104
- tabs : state . tabs . map ( tab => ( { ...tab , result : '' } ) ) ,
104
+ tabs : state . tabs . map ( ( tab ) => ( { ...tab , result : '' } ) ) ,
105
105
} )
106
106
107
- const useTabState = storageNameSpace => {
107
+ const useTabState = ( storageNameSpace ) => {
108
108
const [ state , dispatch ] = useReducer (
109
109
reducer ,
110
110
storageNameSpace ,
@@ -124,7 +124,7 @@ const useTabState = storageNameSpace => {
124
124
} )
125
125
}
126
126
127
- const removeTab = index => {
127
+ const removeTab = ( index ) => {
128
128
dispatch ( {
129
129
type : 'remove' ,
130
130
payload : {
@@ -143,7 +143,7 @@ const useTabState = storageNameSpace => {
143
143
} )
144
144
}
145
145
146
- const setActiveTab = index => {
146
+ const setActiveTab = ( index ) => {
147
147
dispatch ( {
148
148
type : 'setActive' ,
149
149
payload : {
@@ -166,14 +166,13 @@ const useTabState = storageNameSpace => {
166
166
export const useTabs = ( ) => {
167
167
const { baseUrl } = useConfig ( )
168
168
const storageNameSpace = `playground-${ baseUrl } `
169
- const [ state , { addTab, removeTab, editTab, setActiveTab } ] = useTabState (
170
- storageNameSpace
171
- )
169
+ const [ state , { addTab, removeTab, editTab, setActiveTab } ] =
170
+ useTabState ( storageNameSpace )
172
171
173
- const setName = name => editTab ( state . activeTab , { name } )
174
- const setQuery = query => editTab ( state . activeTab , { query } )
175
- const setResult = result => editTab ( state . activeTab , { result } )
176
- const setType = type => editTab ( state . activeTab , { type } )
172
+ const setName = ( name ) => editTab ( state . activeTab , { name } )
173
+ const setQuery = ( query ) => editTab ( state . activeTab , { query } )
174
+ const setResult = ( result ) => editTab ( state . activeTab , { result } )
175
+ const setType = ( type ) => editTab ( state . activeTab , { type } )
177
176
178
177
return {
179
178
activeTab : state . activeTab ,
0 commit comments