77 isConfigValueValid ,
88} from "./config-validation" ;
99import * as ConfigEvent from "./observables/config-event" ;
10- import DefaultConfig from "./constants/default-config" ;
1110import { isAuthenticated } from "./firebase" ;
1211import * as AnalyticsController from "./controllers/analytics-controller" ;
1312import * as AccountButton from "./elements/account-button" ;
@@ -29,14 +28,15 @@ import { Language, LanguageSchema } from "@monkeytype/contracts/schemas/util";
2928import { LocalStorageWithSchema } from "./utils/local-storage-with-schema" ;
3029import { migrateConfig } from "./utils/config" ;
3130import { roundTo1 } from "@monkeytype/util/numbers" ;
31+ import { getDefaultConfig } from "./constants/default-config" ;
3232
3333const configLS = new LocalStorageWithSchema ( {
3434 key : "config" ,
3535 schema : ConfigSchemas . ConfigSchema ,
36- fallback : DefaultConfig ,
36+ fallback : getDefaultConfig ( ) ,
3737 migrate : ( value , _issues ) => {
3838 if ( ! isObject ( value ) ) {
39- return DefaultConfig ;
39+ return getDefaultConfig ( ) ;
4040 }
4141 //todo maybe send a full config to db so that it removes legacy values
4242
@@ -47,7 +47,7 @@ const configLS = new LocalStorageWithSchema({
4747let loadDone : ( value ?: unknown ) => void ;
4848
4949const config = {
50- ...DefaultConfig ,
50+ ...getDefaultConfig ( ) ,
5151} ;
5252
5353let configToSend = { } as Config ;
@@ -1095,7 +1095,7 @@ export function setTimeConfig(
10951095 time : ConfigSchemas . TimeConfig ,
10961096 nosave ?: boolean
10971097) : boolean {
1098- time = isNaN ( time ) || time < 0 ? DefaultConfig . time : time ;
1098+ time = isNaN ( time ) || time < 0 ? getDefaultConfig ( ) . time : time ;
10991099 if ( ! isConfigValueValid ( "time" , time , ConfigSchemas . TimeConfigSchema ) )
11001100 return false ;
11011101
@@ -1168,7 +1168,7 @@ export function setWordCount(
11681168 nosave ?: boolean
11691169) : boolean {
11701170 wordCount =
1171- wordCount < 0 || wordCount > 100000 ? DefaultConfig . words : wordCount ;
1171+ wordCount < 0 || wordCount > 100000 ? getDefaultConfig ( ) . words : wordCount ;
11721172
11731173 if ( ! isConfigValueValid ( "words" , wordCount , ConfigSchemas . WordCountSchema ) )
11741174 return false ;
@@ -1382,7 +1382,7 @@ export function setAutoSwitchTheme(
13821382 return false ;
13831383 }
13841384
1385- boolean = boolean ?? DefaultConfig . autoSwitchTheme ;
1385+ boolean = boolean ?? getDefaultConfig ( ) . autoSwitchTheme ;
13861386 config . autoSwitchTheme = boolean ;
13871387 saveToLocalStorage ( "autoSwitchTheme" , nosave ) ;
13881388 ConfigEvent . dispatch ( "autoSwitchTheme" , config . autoSwitchTheme ) ;
@@ -1985,9 +1985,9 @@ export async function apply(
19851985 ConfigEvent . dispatch ( "fullConfigChange" ) ;
19861986
19871987 const configObj = configToApply as Config ;
1988- ( Object . keys ( DefaultConfig ) as ( keyof Config ) [ ] ) . forEach ( ( configKey ) => {
1988+ ( Object . keys ( getDefaultConfig ( ) ) as ( keyof Config ) [ ] ) . forEach ( ( configKey ) => {
19891989 if ( configObj [ configKey ] === undefined ) {
1990- const newValue = DefaultConfig [ configKey ] ;
1990+ const newValue = getDefaultConfig ( ) [ configKey ] ;
19911991 ( configObj [ configKey ] as typeof newValue ) = newValue ;
19921992 }
19931993 } ) ;
@@ -2095,7 +2095,7 @@ export async function apply(
20952095}
20962096
20972097export async function reset ( ) : Promise < void > {
2098- await apply ( DefaultConfig ) ;
2098+ await apply ( getDefaultConfig ( ) ) ;
20992099 await DB . resetConfig ( ) ;
21002100 saveFullConfigToLocalStorage ( true ) ;
21012101}
@@ -2116,7 +2116,7 @@ export function getConfigChanges(): Partial<Config> {
21162116 const configChanges : Partial < Config > = { } ;
21172117 typedKeys ( config )
21182118 . filter ( ( key ) => {
2119- return config [ key ] !== DefaultConfig [ key ] ;
2119+ return config [ key ] !== getDefaultConfig ( ) [ key ] ;
21202120 } )
21212121 . forEach ( ( key ) => {
21222122 //@ts -expect-error this is fine
0 commit comments