Skip to content

Commit

Permalink
cancel button fix
Browse files Browse the repository at this point in the history
  • Loading branch information
phughesmcr committed Sep 3, 2024
1 parent ae2dbb3 commit 187c412
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions components/DebateFormInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MIN_DEBATE_ROUNDS,
} from "lib/debate/inputValidation.ts";
import { Personality } from "lib/debate/personalities.ts";
import { FunctionComponent } from "preact";


interface DebateFormInputsProps {
Expand All @@ -27,6 +26,8 @@ interface DebateFormInputsProps {
isDebating: boolean;
handleSubmit: (e: Event) => void;
cancelDebate: () => void;
enableModerator: boolean;
setEnableModerator: (value: boolean) => void;
}

const EXAMPLE_POSITIONS = [
Expand All @@ -42,7 +43,7 @@ const EXAMPLE_POSITIONS = [
"Coffee is better than sleep",
];

const DebateFormInputs: FunctionComponent<DebateFormInputsProps> = ({
const DebateFormInputs = ({
position,
setPosition,
numAgents,
Expand All @@ -60,7 +61,7 @@ const DebateFormInputs: FunctionComponent<DebateFormInputsProps> = ({
cancelDebate,
enableModerator,
setEnableModerator,
}) => {
}: DebateFormInputsProps) => {
return (
<form
onSubmit={(e) => {
Expand Down
8 changes: 6 additions & 2 deletions hooks/useDebateState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function useDebateState() {
setIsDebating(false);
abortControllerRef.current = null;
}
}, [position, context, numAgents, numDebateRounds, agentDetails, enableModerator, userUUID]);
}, [position, numAgents, numDebateRounds, agentDetails, enableModerator, userUUID]);

const cancelDebate = useCallback(() => {
if (abortControllerRef.current) {
Expand All @@ -196,8 +196,12 @@ export function useDebateState() {
setLoading(false);
setDebate([]);
setIsDebateFinished(false);
setErrors([]);
setPosition("");
setContext("");
updateAgentDetails(numAgents);
}
}, []);
}, [numAgents, updateAgentDetails]);

const safeSetNumDebateRounds = useCallback((value: number | string) => {
const parsedValue = parseInt(value as string, 10);
Expand Down

0 comments on commit 187c412

Please sign in to comment.