1+ import {
2+ UserPreferences as Preferences ,
3+ AppThemeOptions
4+ } from '../../../../common/types' ;
15import * as ActionTypes from '../../../constants' ;
26import i18n from '../../../i18n' ;
37
4- export const initialState = {
8+ export interface PreferencesState
9+ extends Omit < Preferences , 'indentationAmount' | 'isTabIndent' > {
10+ tabIndex : number ;
11+ }
12+
13+ // prettier-ignore
14+ export type PreferencesAction =
15+ | { type : typeof ActionTypes . OPEN_PREFERENCES }
16+ | { type : typeof ActionTypes . SET_PREFERENCES_TAB ; value : number }
17+ | { type : typeof ActionTypes . SET_FONT_SIZE ; value : Preferences [ 'fontSize' ] }
18+ | { type : typeof ActionTypes . SET_AUTOSAVE ; value : Preferences [ 'autosave' ] }
19+ | { type : typeof ActionTypes . SET_LINEWRAP ; value : Preferences [ 'linewrap' ] }
20+ | { type : typeof ActionTypes . SET_LINT_WARNING ; value : Preferences [ 'lintWarning' ] }
21+ | { type : typeof ActionTypes . SET_TEXT_OUTPUT ; value : Preferences [ 'textOutput' ] }
22+ | { type : typeof ActionTypes . SET_GRID_OUTPUT ; value : Preferences [ 'gridOutput' ] }
23+ | { type : typeof ActionTypes . SET_PREFERENCES ; preferences : PreferencesState }
24+ | { type : typeof ActionTypes . SET_THEME ; value : Preferences [ 'theme' ] }
25+ | { type : typeof ActionTypes . SET_AUTOREFRESH ; value : Preferences [ 'autorefresh' ] }
26+ | { type : typeof ActionTypes . SET_LINE_NUMBERS ; value : Preferences [ 'lineNumbers' ] }
27+ | { type : typeof ActionTypes . SET_LANGUAGE ; language : Preferences [ 'language' ] }
28+ | { type : typeof ActionTypes . SET_AUTOCLOSE_BRACKETS_QUOTES ; value : Preferences [ 'autocloseBracketsQuotes' ] }
29+ | { type : typeof ActionTypes . SET_AUTOCOMPLETE_HINTER ; value : Preferences [ 'autocompleteHinter' ] } ;
30+
31+ export const initialState : PreferencesState = {
532 tabIndex : 0 ,
633 fontSize : 18 ,
734 autosave : true ,
@@ -10,14 +37,17 @@ export const initialState = {
1037 lintWarning : false ,
1138 textOutput : false ,
1239 gridOutput : false ,
13- theme : 'light' ,
40+ theme : AppThemeOptions . LIGHT ,
1441 autorefresh : false ,
1542 language : i18n . language ,
1643 autocloseBracketsQuotes : true ,
1744 autocompleteHinter : false
1845} ;
1946
20- export const preferences = ( state = initialState , action ) => {
47+ export const preferences = (
48+ state : PreferencesState = initialState ,
49+ action : PreferencesAction
50+ ) => {
2151 switch ( action . type ) {
2252 case ActionTypes . OPEN_PREFERENCES :
2353 return Object . assign ( { } , state , { tabIndex : 0 } ) ;
0 commit comments