Skip to content

Commit 0b981ee

Browse files
committed
feat: ignore all sensors starting with "_"
Signed-off-by: Pedro Lamas <[email protected]>
1 parent 5a2e650 commit 0b981ee

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/store/printer/getters.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,11 @@ export const getters: GetterTree<PrinterState, RootState> = {
509509

510510
if (
511511
supportedTypes.includes(type) &&
512-
(
513-
(filterByPrefix.includes(type) && !name.startsWith('_')) ||
514-
!filterByPrefix.includes(type)
515-
)
512+
(!filterByPrefix.includes(type) || !name.startsWith('_'))
516513
) {
517-
let prettyName = Vue.$filters.startCase(name)
518-
if (name === 'fan') prettyName = 'Part Fan' // If we know its the part fan.
514+
const prettyName = name === 'fan'
515+
? 'Part Fan' // If we know its the part fan.
516+
: Vue.$filters.startCase(name)
519517

520518
const color = (applyColor.includes(type))
521519
? Vue.$colorset.next(getKlipperType(pin), pin)
@@ -630,8 +628,11 @@ export const getters: GetterTree<PrinterState, RootState> = {
630628
const printerKeys = Object.keys(state.printer)
631629

632630
const sensors = keyGroups.flatMap(keyGroup => {
631+
const keyGroupRegExpArray = keyGroup
632+
.map(x => new RegExp(`^${x}(?! _)`))
633+
633634
return printerKeys
634-
.filter(key => keyGroup.some(x => key.startsWith(x)))
635+
.filter(key => keyGroupRegExpArray.some(x => x.test(key)))
635636
.sort((a, b) => a.localeCompare(b))
636637
})
637638

0 commit comments

Comments
 (0)