This commit is contained in:
James Ketr 2025-05-22 17:10:55 -07:00
parent ceb96d1bd5
commit c77f260963

View File

@ -41,11 +41,9 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
const [streaming, setStreaming] = useState<string>('');
const [processing, setProcessing] = useState<boolean>(false);
const [user, setUser] = useState<UserInfo>(emptyUser);
const [userTimestamp, setUserTimestamp] = useState<number>(0);
const [prompt, setPrompt] = useState<string>('');
const [resume, setResume] = useState<string>('');
const [canGenImage, setCanGenImage] = useState<boolean>(false);
const [hasProfile, setHasProfile] = useState<boolean>(false);
const [status, setStatus] = useState<string>('');
const [timestamp, setTimestamp] = useState<number>(0);
const [state, setState] = useState<number>(0); // Replaced stateRef
@ -98,7 +96,6 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
controllerRef.current = null;
setState(0);
setCanGenImage(true);
setHasProfile(true);
setShouldGenerateProfile(false);
setUser({ ...user, has_profile: true });
}
@ -110,7 +107,6 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
controllerRef.current = null;
setState(0);
setCanGenImage(true);
setHasProfile(true); /* Hack for now */
setShouldGenerateProfile(false);
break;
default:
@ -123,7 +119,7 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
} else {
setTimestamp(Date.now())
}
if (data.message !== '') {
if (data.message) {
setStatus(data.message);
}
break;
@ -272,7 +268,6 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
controllerRef.current = null;
setState(0);
setCanGenImage(true);
setHasProfile(true);
setShouldGenerateProfile(false);
}
break;
@ -283,7 +278,6 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
controllerRef.current = null;
setState(0);
setCanGenImage(true);
setHasProfile(true);
setShouldGenerateProfile(false);
break;
default:
@ -334,10 +328,6 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
}
}, [streaming, state]);
useEffect(() => {
setUserTimestamp(Date.now());
}, [user]);
if (!sessionId) {
return <></>;
}
@ -368,7 +358,7 @@ const GenerateCandidate = (props: BackstoryElementProps) => {
<Box sx={{ display: "flex", flexDirection: "row", position: "relative" }}>
<Box sx={{ display: "flex", position: "relative" }}>
<Avatar
src={hasProfile ? `/api/u/${user.username}/profile/${sessionId}` : ''}
src={user.has_profile ? `/api/u/${user.username}/profile/${sessionId}` : ''}
alt={`${user.full_name}'s profile`}
sx={{
width: 80,