mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-01 12:46:07 +00:00
web: load turnstile only in save tab and only once
turnstile will stay in background after being loaded once (just like before), but now it will not load on pages other than save if they are opened first
This commit is contained in:
parent
f0f5d7be7e
commit
49460bd16d
|
@ -2,7 +2,7 @@
|
|||
import env from "$lib/env";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
import { turnstileLoaded } from "$lib/state/turnstile";
|
||||
import { turnstileLoaded, turnstileCreated } from "$lib/state/turnstile";
|
||||
|
||||
let turnstileElement: HTMLElement;
|
||||
let turnstileScript: HTMLElement;
|
||||
|
@ -10,6 +10,9 @@
|
|||
onMount(() => {
|
||||
const sitekey = env.TURNSTILE_KEY;
|
||||
if (!sitekey) return;
|
||||
|
||||
$turnstileCreated = true;
|
||||
|
||||
const setup = () => {
|
||||
window.turnstile?.render(turnstileElement, {
|
||||
sitekey,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { writable } from "svelte/store";
|
||||
|
||||
export const turnstileLoaded = writable(false);
|
||||
export const turnstileCreated = writable(false);
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
<script lang="ts">
|
||||
import { afterNavigate } from "$app/navigation";
|
||||
import { updated } from "$app/stores";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
import env from "$lib/env";
|
||||
import settings from "$lib/state/settings";
|
||||
import { device, app } from "$lib/device";
|
||||
import locale from "$lib/i18n/locale";
|
||||
import currentTheme, { statusBarColors } from "$lib/state/theme";
|
||||
|
||||
import "@fontsource/ibm-plex-mono/400.css";
|
||||
import "@fontsource/ibm-plex-mono/400-italic.css";
|
||||
import "@fontsource/ibm-plex-mono/500.css";
|
||||
|
||||
import { page } from "$app/stores";
|
||||
import { updated } from "$app/stores";
|
||||
import { browser } from "$app/environment";
|
||||
import { afterNavigate } from "$app/navigation";
|
||||
|
||||
import env from "$lib/env";
|
||||
import settings from "$lib/state/settings";
|
||||
import locale from "$lib/i18n/locale";
|
||||
|
||||
import { device, app } from "$lib/device";
|
||||
import { turnstileCreated } from "$lib/state/turnstile";
|
||||
import currentTheme, { statusBarColors } from "$lib/state/theme";
|
||||
|
||||
import Sidebar from "$components/sidebar/Sidebar.svelte";
|
||||
import Turnstile from "$components/misc/Turnstile.svelte";
|
||||
import NotchSticker from "$components/misc/NotchSticker.svelte";
|
||||
|
@ -64,7 +67,7 @@
|
|||
<DialogHolder />
|
||||
<Sidebar />
|
||||
<div id="content">
|
||||
{#if env.TURNSTILE_KEY}
|
||||
{#if (env.TURNSTILE_KEY && $page.url.pathname === "/") || $turnstileCreated}
|
||||
<Turnstile />
|
||||
{/if}
|
||||
<slot></slot>
|
||||
|
|
Loading…
Reference in a new issue