Skip to content

Commit

Permalink
improve typing for debug commands
Browse files Browse the repository at this point in the history
  • Loading branch information
noahm committed May 16, 2024
1 parent b40467d commit 1344e65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 1 addition & 8 deletions ui/DebugCommands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useAtomValue } from "jotai";
import { useState } from "react";
import { DEBUG_COMMANDS } from "./pad-coms";
import { selectedStage$ } from "./state.ts";
import { RGB } from "../sdk/utils.ts";

const cmds = Array.from(Object.entries(DEBUG_COMMANDS));

Expand All @@ -13,13 +12,7 @@ export function DebugCommands() {
selectedCommand && stage
? async () => {
const cmd = DEBUG_COMMANDS[selectedCommand];
if (cmd === "setLightStrip") {
// TODO: We don't even expose this to the dropdown, but this seemed
// like the easiest fix for now.
await stage[cmd](new RGB(0, 0, 255));
} else {
await stage[cmd]();
}
await stage[cmd]();
}
: undefined;
return (
Expand Down
4 changes: 2 additions & 2 deletions ui/pad-coms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ type FunctionKeys<T extends object> = keyof {
};

/** anything here will appear in the debug UI to dispatch at will */
export const DEBUG_COMMANDS: Record<string, FunctionKeys<SMXStage>> = {
export const DEBUG_COMMANDS = {
requestConfig: "updateConfig",
writeConfig: "writeConfig",
requestTestData: "updateTestData",
forceRecalibration: "forceRecalibration",
factoryReset: "factoryReset",
};
} as const satisfies Record<string, FunctionKeys<SMXStage>>;

0 comments on commit 1344e65

Please sign in to comment.