Skip to content

Commit

Permalink
refactor: remove magic numbers
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
meteyou committed May 26, 2024
1 parent 97fc98a commit 0f14149
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/store/printer/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,13 @@ export const getters: GetterTree<PrinterState, RootState> = {
const settings = state.configfile?.settings ?? null
const printerGcodes = state.gcode?.commands ?? {}

const prefix = 'gcode_macro '
const prefixLength = prefix.length

Object.keys(state)
.filter((prop) => prop.toLowerCase().startsWith('gcode_macro '))
.filter((prop) => prop.toLowerCase().startsWith(prefix))
.forEach((prop) => {
const name = prop.slice(12)
const name = prop.slice(prefixLength)
const printerGcode = printerGcodes[name.toUpperCase()] ?? {}

// remove macros with a '_' as first char
Expand Down

0 comments on commit 0f14149

Please sign in to comment.