Skip to content

Commit 9aa3f91

Browse files
committed
fix: do least amount of searches, but fallback
1 parent ad485e2 commit 9aa3f91

File tree

1 file changed

+22
-22
lines changed
  • packages/input-manager/src/integrations/streamdeck

1 file changed

+22
-22
lines changed

packages/input-manager/src/integrations/streamdeck/device.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -272,31 +272,31 @@ export class StreamDeckDeviceHandler {
272272

273273
// Find the first match
274274
for (const name of styleClassNames) {
275-
let stylePreset = Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
276-
(preset) => preset.id === name
277-
)
275+
let stylePreset: StreamdeckStylePreset | undefined
278276
if (feedback.tally) {
279277
if (feedback.tally & Tally.ACTIVE) {
280-
stylePreset =
281-
Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
282-
(preset) => preset.id === `${name}:active`
283-
) || stylePreset
284-
} else if (feedback.tally & Tally.NEXT) {
285-
stylePreset =
286-
Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
287-
(preset) => preset.id === `${name}:next`
288-
) || stylePreset
289-
} else if (feedback.tally & Tally.OTHER) {
290-
stylePreset =
291-
Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
292-
(preset) => preset.id === `${name}:other`
293-
) || stylePreset
294-
} else if (feedback.tally & Tally.PRESENT) {
295-
stylePreset =
296-
Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
297-
(preset) => preset.id === `${name}:present`
298-
) || stylePreset
278+
stylePreset = Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
279+
(preset) => preset.id === `${name}:active`
280+
)
281+
}
282+
if (feedback.tally & Tally.NEXT && !stylePreset) {
283+
stylePreset = Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
284+
(preset) => preset.id === `${name}:next`
285+
)
286+
}
287+
if (feedback.tally & Tally.OTHER && !stylePreset) {
288+
stylePreset = Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
289+
(preset) => preset.id === `${name}:other`
290+
)
299291
}
292+
if (feedback.tally & Tally.PRESENT && !stylePreset) {
293+
stylePreset = Object.values<StreamdeckStylePreset>(this.config.stylePresets).find(
294+
(preset) => preset.id === `${name}:present`
295+
)
296+
}
297+
}
298+
if (!stylePreset) {
299+
Object.values<StreamdeckStylePreset>(this.config.stylePresets).find((preset) => preset.id === name)
300300
}
301301

302302
if (stylePreset) {

0 commit comments

Comments
 (0)