File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -527,8 +527,6 @@ describe("Config", () => {
527527 expect ( Config . setCustomThemeColors ( customThemeColors ( 10 ) ) ) . toBe ( true ) ;
528528
529529 expect ( Config . setCustomThemeColors ( customThemeColors ( 9 ) ) ) . toBe ( false ) ;
530- expect ( Config . setCustomThemeColors ( [ ] as any ) ) . toBe ( false ) ;
531- expect ( Config . setCustomThemeColors ( [ "invalid" ] as any ) ) . toBe ( false ) ;
532530 expect ( Config . setCustomThemeColors ( customThemeColors ( 5 ) ) ) . toBe ( false ) ;
533531 expect ( Config . setCustomThemeColors ( customThemeColors ( 11 ) ) ) . toBe ( false ) ;
534532
@@ -931,7 +929,9 @@ describe("Config", () => {
931929} ) ;
932930
933931function customThemeColors ( n : number ) : CustomThemeColors {
934- return new Array ( n ) . fill ( "#000" ) as CustomThemeColors ;
932+ const arr = new Array ( n ) . fill ( "#000" ) as CustomThemeColors ;
933+ arr [ 0 ] = "#123456" ; // we have a protection against all colors being the same
934+ return arr ;
935935}
936936
937937function testBoolean ( fn : ( val : boolean ) => boolean ) : void {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { isDevEnvironment, reloadAfter } from "./utils/misc";
77import * as ConfigSchemas from "@monkeytype/schemas/configs" ;
88import { roundTo1 } from "@monkeytype/util/numbers" ;
99import { capitalizeFirstLetter } from "./utils/strings" ;
10+ import { getDefaultConfig } from "./constants/default-config" ;
1011// type SetBlock = {
1112// [K in keyof ConfigSchemas.Config]?: ConfigSchemas.Config[K][];
1213// };
@@ -710,6 +711,14 @@ export const configMetadata: ConfigMetadataObject = {
710711 icon : "fa-palette" ,
711712 displayString : "custom theme colors" ,
712713 changeRequiresRestart : false ,
714+ overrideValue : ( { value } ) => {
715+ const allColorsThesame = value . every ( ( color ) => color === value [ 0 ] ) ;
716+ if ( allColorsThesame ) {
717+ return getDefaultConfig ( ) . customThemeColors ;
718+ } else {
719+ return value ;
720+ }
721+ } ,
713722 } ,
714723
715724 // hide elements
You can’t perform that action at this time.
0 commit comments