From 9af4fd89f67ef49a31c779231ab79e985e04acb8 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 25 Feb 2022 04:16:52 -0500 Subject: [PATCH] fix another bug --- .../subforms/BitsCheermoteNameExactMatchForm.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermoteNameExactMatchForm.tsx b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermoteNameExactMatchForm.tsx index a17ed63395..0ff460078f 100644 --- a/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermoteNameExactMatchForm.tsx +++ b/packages/storyteller/src/pages/tts_configs/event_match_predicate_builder/subforms/BitsCheermoteNameExactMatchForm.tsx @@ -25,16 +25,21 @@ function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps // https://stackoverflow.com/a/62982753 useEffect(() => { let newPrefix = ''; - let newBits = 1; let newFullName = ''; + let newBits = 1; + let hasBits = false; + + if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { + newBits = props.cheerState.bits; + hasBits = true; + } if (CheerStateIsOfficial(props.cheerState)) { if (!!props.cheerState.cheerPrefix) { newPrefix = CHEER_PREFIX_TO_STRING_MAP.get((props.cheerState.cheerPrefix)) || ''; } - if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { - newBits = props.cheerState.bits; + if (hasBits) { newFullName = `${newPrefix}${newBits}`; } else { newFullName = newPrefix; @@ -42,10 +47,6 @@ function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps } else if (CheerStateIsCustom(props.cheerState)) { newFullName = props.cheerState.cheerFull || ''; - - if (!!props.cheerState.bits && !isNaN(props.cheerState.bits) && props.cheerState.bits > 0) { - newBits = props.cheerState.bits; - } } setCheerPrefix(newPrefix);