Skip to content

Commit

Permalink
Fixed search context state
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoAbove committed Aug 13, 2024
1 parent 122e25d commit 4f3f7e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/SearchSeeds/SearchContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const SearchContextProvider: FC<{ children: React.ReactNode }> = ({ children })
const [clusterHelpEnabled, setClusterHelpEnabled] = useState(false);
const [clusterConnected, setClusterConnected] = useState(false);
const [socketComputeProvider, setSocketComputeProvider] = useState<SocketComputeProvider>();
const [callbackComputeHandler, setCallbackComputeHandler] = useState<CallbackComputeHandler>();
const [computeVersionMismatch, setComputeVersionMismatch] = useState<boolean>(false);

// Load query data when currentSearchUUID changes
Expand Down Expand Up @@ -138,6 +139,8 @@ const SearchContextProvider: FC<{ children: React.ReactNode }> = ({ children })

const newCallbackComputeHandler = new CallbackComputeHandler(setSolverStatus, chunkProvider, ruleTree, seedSolver);

setCallbackComputeHandler(newCallbackComputeHandler);

return () => {
newCallbackComputeHandler.destruct();
};
Expand Down Expand Up @@ -235,15 +238,15 @@ const SearchContextProvider: FC<{ children: React.ReactNode }> = ({ children })
};
fetch("/api/data", requestOptions).catch(console.error);
socketComputeProvider?.start();
await CallbackComputeHandler.prototype.start?.().catch(console.error);
}, [ruleTree, socketComputeProvider]);
callbackComputeHandler?.start().catch(console.error);
}, [ruleTree, socketComputeProvider, callbackComputeHandler]);

const stopCalculation = useCallback(async () => {
socketComputeProvider?.stop();
if (!chunkProvider?.customSeeds?.length) {
await CallbackComputeHandler.prototype.stop?.();
await callbackComputeHandler?.stop();
}
}, [socketComputeProvider, chunkProvider]);
}, [socketComputeProvider, callbackComputeHandler, chunkProvider]);

const handleCopy = useCallback(() => {
const seedList = chunkProvider?.results.size ? [...chunkProvider.results.values()] : [];
Expand Down

0 comments on commit 4f3f7e4

Please sign in to comment.