@@ -101,11 +101,13 @@ import * as FPSCounter from "../elements/fps-counter";
101101import {
102102 CustomBackgroundSchema ,
103103 CustomLayoutFluid ,
104+ CustomLayoutFluidSchema ,
105+ CustomPolyglot ,
106+ CustomPolyglotSchema ,
104107} from "@monkeytype/contracts/schemas/configs" ;
105- import { Command , CommandsSubgroup } from "./types" ;
108+ import { Command , CommandsSubgroup , withValidation } from "./types" ;
106109import * as TestLogic from "../test/test-logic" ;
107110import * as ActivePage from "../states/active-page" ;
108- import { Language } from "@monkeytype/contracts/schemas/languages" ;
109111
110112const fontsPromise = JSONData . getFontsList ( ) ;
111113fontsPromise
@@ -189,37 +191,39 @@ export const commands: CommandsSubgroup = {
189191 ...LanguagesCommands ,
190192 ...BritishEnglishCommands ,
191193 ...FunboxCommands ,
192- {
194+ withValidation ( {
193195 id : "changeCustomLayoutfluid" ,
194196 display : "Custom layoutfluid..." ,
195197 defaultValue : ( ) : string => {
196198 return Config . customLayoutfluid . join ( " " ) ;
197199 } ,
198200 input : true ,
199201 icon : "fa-tint" ,
202+ inputValueConvert : ( val ) => val . trim ( ) . split ( " " ) as CustomLayoutFluid ,
203+ validation : { schema : CustomLayoutFluidSchema } ,
200204 exec : ( { input } ) : void => {
201205 if ( input === undefined ) return ;
202- UpdateConfig . setCustomLayoutfluid (
203- input . split ( " " ) as CustomLayoutFluid
204- ) ;
206+ UpdateConfig . setCustomLayoutfluid ( input ) ;
205207 } ,
206- } ,
207- {
208+ } ) ,
209+ withValidation ( {
208210 id : "changeCustomPolyglot" ,
209211 display : "Polyglot languages..." ,
210212 defaultValue : ( ) : string => {
211213 return Config . customPolyglot . join ( " " ) ;
212214 } ,
213215 input : true ,
214216 icon : "fa-language" ,
217+ inputValueConvert : ( val ) => val . trim ( ) . split ( " " ) as CustomPolyglot ,
218+ validation : { schema : CustomPolyglotSchema } ,
215219 exec : ( { input } ) : void => {
216220 if ( input === undefined ) return ;
217- void UpdateConfig . setCustomPolyglot ( input . split ( " " ) as Language [ ] ) ;
221+ void UpdateConfig . setCustomPolyglot ( input ) ;
218222 if ( ActivePage . get ( ) === "test" ) {
219223 TestLogic . restart ( ) ;
220224 }
221225 } ,
222- } ,
226+ } ) ,
223227
224228 //input
225229 ...FreedomModeCommands ,
0 commit comments