Skip to content

Commit

Permalink
Add cookie to store history
Browse files Browse the repository at this point in the history
  • Loading branch information
Elscrux committed Nov 9, 2023
1 parent 59786da commit dcc7725
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/solvers/ProgressHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Center, HStack } from "@chakra-ui/react";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { useCookies } from "react-cookie";
import { History } from "./History";
import { GoButton } from "./buttons/GoButton";
import { fetchSolution, postProblem } from "../../api/ToolboxAPI";
Expand Down Expand Up @@ -44,6 +45,15 @@ export const ProgressHandler = <T extends {}>(
requestContent: props.problemInput,
requestedSubSolveRequests: {},
});
const [cookies, setCookie, removeCookie] = useCookies(["problemStates"]);

useEffect(() => {
// Handle problem states cookies
if (problemStates.length == 0 && cookies.problemStates?.length > 0) {
setProblemStates(cookies.problemStates);
}
setCookie("problemStates", problemStates);
}, [problemStates, cookies, setCookie]);

async function getSolution() {
setClicked(true);
Expand Down

0 comments on commit dcc7725

Please sign in to comment.