MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / replaceLegacyValues

Function replaceLegacyValues

frontend/src/ts/config/utils.ts:42–223  ·  view source on GitHub ↗
(
  configObj: ConfigSchemas.PartialConfig,
)

Source from the content-addressed store, hash-verified

40}
41
42function replaceLegacyValues(
43 configObj: ConfigSchemas.PartialConfig,
44): ConfigSchemas.PartialConfig {
45 //@ts-expect-error legacy configs
46 if (configObj.quickTab === true && configObj.quickRestart === undefined) {
47 configObj.quickRestart = "tab";
48 }
49
50 if (typeof configObj.smoothCaret === "boolean") {
51 configObj.smoothCaret = configObj.smoothCaret ? "medium" : "off";
52 }
53
54 if (
55 //@ts-expect-error legacy configs
56 configObj.swapEscAndTab === true &&
57 configObj.quickRestart === undefined
58 ) {
59 configObj.quickRestart = "esc";
60 }
61
62 if (
63 //@ts-expect-error legacy configs
64 configObj.alwaysShowCPM === true &&
65 configObj.typingSpeedUnit === undefined
66 ) {
67 configObj.typingSpeedUnit = "cpm";
68 }
69
70 //@ts-expect-error legacy configs
71 if (configObj.showAverage === "wpm") {
72 configObj.showAverage = "speed";
73 }
74
75 if (typeof configObj.playSoundOnError === "boolean") {
76 configObj.playSoundOnError = configObj.playSoundOnError ? "1" : "off";
77 }
78
79 if (
80 //@ts-expect-error legacy configs
81 configObj.showTimerProgress === false &&
82 configObj.timerStyle === undefined
83 ) {
84 configObj.timerStyle = "off";
85 }
86
87 if (
88 //@ts-expect-error legacy configs
89 configObj.showLiveWpm === true &&
90 configObj.liveSpeedStyle === undefined
91 ) {
92 let val: ConfigSchemas.LiveSpeedAccBurstStyle = "mini";
93 if (configObj.timerStyle !== "bar" && configObj.timerStyle !== "off") {
94 val = configObj.timerStyle as ConfigSchemas.LiveSpeedAccBurstStyle;
95 }
96 configObj.liveSpeedStyle = val;
97 }
98
99 if (

Callers 1

migrateConfigFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected