This commit is contained in:
Brandon Thomas committed 2022-02-25 01:07:51 -05:00
1 parent d2c71fa84c
commit f513e5630c
3 files changed
+23 -14

No files matched your search

@@ -1,5 +1,5 @@
import { EventMatchPredicate } from "@storyteller/components/src/api/storyteller/twitch_event_rules/shared/EventMatchPredicate";
import { CHEER_LOOKUP_MAP, TwitchCheerPrefix } from "../../../twitch/Cheers";
import { CHEER_LOOKUP_MAP, CHEER_PREFIX_TO_STRING_MAP, TwitchCheerPrefix } from "../../../twitch/Cheers";
import { CheerUtil } from "../../../twitch/CheerUtil";
import { BitsRuleType } from "./types/BitsRuleType";
@@ -106,20 +106,29 @@ export function cheerStateToPredicate(
switch (bitsRuleType) {
case BitsRuleType.BitsCheermoteNameExactMatch:
// TODO
// TODO
// TODO
// TODO
let cheermoteName = '';
if (CheerStateIsOfficial(cheerState)) {
// TODO
let cheerPrefix = '';
let bitsValue = '';
if (!!cheerState.cheerPrefix) {
cheerPrefix = CHEER_PREFIX_TO_STRING_MAP.get(cheerState.cheerPrefix) || '';
}
if (!!cheerState.bits && !isNaN(cheerState.bits) && cheerState.bits > 1) {
bitsValue = cheerState.bits.toString();
}
if (!!cheerPrefix) {
// Don't bother setting unless we have a prefix
cheermoteName = `${cheerPrefix}${bitsValue}`
}
} else if (CheerStateIsCustom(cheerState)) {
// TODO
// TODO
// TODO
// TODO
}
predicate.bits_cheermote_name_exact_match = {
cheermote_name: '',
cheermote_name: cheermoteName,
}
break;
case BitsRuleType.BitsCheermotePrefixSpendThreshold:
@@ -279,10 +279,13 @@ function EventMatchPredicateBuilderComponent(props: EventMatchPredicateBuilderCo
setCheerState(newCheerState);
let predicate = cheerStateToPredicate(newCheerState, bitsRuleType);
console.log('\n\n======== handleChangedMinimumBitsSpend() =======');
console.log('cheerState', newCheerState);
console.table(predicate)
console.log('\n\n');
//switch (bitsRuleType) {
// case BitsRuleType.BitsCheermoteNameExactMatch:
@@ -103,10 +103,7 @@ function BitsCheermoteNameExactMatchForm(props: BitsCheermoteNameExactMatchProps
}
// When the dropdowns are used, replace any manual text entry.
const recalcuateFieldValue = (prefix: string|undefined, bits: number) => {
if (prefix === undefined) {
return;
}
const recalcuateFieldValue = (prefix: string, bits: number) => {
const cheerValue = `${prefix}${bits}`;
setManualCheerValue(cheerValue);
props.updateCheerName(cheerValue);