Add SkipAgentController component
cgen-78e2c9087879429b841a4e20caa47cd9
This commit is contained in:
parent
e5867c2f49
commit
85dac6cb2b
1 changed files with 25 additions and 0 deletions
25
client/components/SkipAgentController.tsx
Normal file
25
client/components/SkipAgentController.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { useEffect } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
import { setSkipAgentActive } from "@/lib/skip-agent";
|
||||
|
||||
const DOCS_PATH_PREFIX = "/docs";
|
||||
|
||||
const SkipAgentController = () => {
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
const disableForDocs = location.pathname.startsWith(DOCS_PATH_PREFIX);
|
||||
void setSkipAgentActive(!disableForDocs);
|
||||
|
||||
return () => {
|
||||
if (disableForDocs) {
|
||||
void setSkipAgentActive(true);
|
||||
}
|
||||
};
|
||||
}, [location.pathname]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default SkipAgentController;
|
||||
Loading…
Reference in a new issue