Skip to content

Commit

Permalink
Fix some issues with init of turnstile hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain Jack Sparrow committed Jun 4, 2024
1 parent 86a3c42 commit 384cc43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/overlays/OverlayDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useInternalOverlayRouter,
useRouterAnchorUpdate,
} from "@/hooks/useOverlayRouter";
import { TurnstileProvider } from "@/stores/turnstile";
import { TurnstileProvider, getTurnstile } from "@/stores/turnstile";

export interface OverlayProps {
id: string;
Expand All @@ -20,6 +20,7 @@ export interface OverlayProps {
function TurnstileInteractive() {
const { t } = useTranslation();
const [show, setShow] = useState(false);
getTurnstile();

// this may not rerender with different dom structure, must be exactly the same always
return (
Expand Down
3 changes: 3 additions & 0 deletions src/stores/turnstile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export async function getTurnstileToken() {
const turnstile = getTurnstile();
try {
// I hate turnstile
if (turnstile.controls.isExpired()) {
turnstile.controls.reset();
}
(window as any).turnstile.execute(
document.querySelector(`#${turnstile.id}`),
{},
Expand Down

0 comments on commit 384cc43

Please sign in to comment.