UI sorting works

This commit is contained in:
Brandon Thomas committed 2022-02-26 04:54:46 -05:00
1 parent 036e37a120
commit 568f7bd9f6
2 files changed
+30 -4

No files matched your search

@@ -41,6 +41,7 @@ function TtsConfigsReorderPage(props: Props) {
}, []);
useEffect(() => {
console.log('useEffect');
let maybeTwitchEventCategory = TWITCH_EVENT_CATEGORY_BY_STRING.get(event_category);
if (maybeTwitchEventCategory === undefined) {
@@ -53,11 +54,40 @@ function TtsConfigsReorderPage(props: Props) {
}, [listTwitchEventRules, event_category, history]);
const handleMoveUp = (ruleIndex: number) => {
let newEventRules = [...twitchEventRules];
if (ruleIndex >= newEventRules.length || // Walk off end
ruleIndex === 0) { // Can't move up.
return false;
}
let aboveIndex = ruleIndex - 1;
let aboveRule = newEventRules[aboveIndex];
newEventRules[aboveIndex] = newEventRules[ruleIndex];
newEventRules[ruleIndex] = aboveRule;
setTwitchEventRules(newEventRules);
}
const handleMoveDown = (ruleIndex: number) => {
let newEventRules = [...twitchEventRules];
if (ruleIndex < 0 || // Invalid
ruleIndex >= newEventRules.length - 1) { // Can't move down.
return false;
}
let belowIndex = ruleIndex + 1;
console.log(ruleIndex, belowIndex);
let belowRule = newEventRules[belowIndex];
newEventRules[belowIndex] = newEventRules[ruleIndex];
newEventRules[ruleIndex] = belowRule;
setTwitchEventRules(newEventRules);
}
if (!props.sessionWrapper.isLoggedIn()) {
@@ -23,10 +23,6 @@ function ReorderableTwitchEventRuleElement(props: Props) {
let subtitle = <></>;
let description = <></>;
const handleClickUp = (ev: React.FormEvent<HTMLButtonElement>) : boolean => {
return true;
}
if (props.rule.event_match_predicate.bits_cheermote_name_exact_match !== undefined) {
title = "Cheermote Name Matches"
subtitle = (