fix: svelte didn't work the way i thought it did

This commit is contained in:
Sam 2023-06-03 03:17:24 +02:00
parent 8d0c2cce73
commit 3fe654a220
No known key found for this signature in database
GPG key ID: B4EF20DDE721CAA1
4 changed files with 12 additions and 14 deletions

View file

@ -29,8 +29,7 @@
type FieldEntry,
type Pronoun,
} from "$lib/api/entities";
import { PUBLIC_BASE_URL } from "$env/static/public";
import { env } from "$env/dynamic/public";
import { PUBLIC_BASE_URL, PUBLIC_SHORT_BASE } from "$env/static/public";
import { apiFetchClient } from "$lib/api/fetch";
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
import { goto } from "$app/navigation";
@ -120,7 +119,7 @@
};
const copyShortURL = async () => {
const url = `${env.PUBLIC_SHORT_BASE}/${data.sid}`;
const url = `${PUBLIC_SHORT_BASE}/${data.sid}`;
await navigator.clipboard.writeText(url);
addToast({ body: "Copied the short link to your clipboard!", duration: 2000 });
};
@ -239,7 +238,7 @@
<Button color="secondary" outline on:click={copyURL}>
<Icon name="clipboard" /> Copy link
</Button>
{#if env.PUBLIC_SHORT_BASE}
{#if PUBLIC_SHORT_BASE}
<IconButton
outline
icon="link-45deg"

View file

@ -12,8 +12,7 @@
type FieldEntry,
type Pronoun,
} from "$lib/api/entities";
import { PUBLIC_BASE_URL } from "$env/static/public";
import { env } from "$env/dynamic/public";
import { PUBLIC_BASE_URL, PUBLIC_SHORT_BASE } from "$env/static/public";
import { userStore } from "$lib/store";
import { renderMarkdown } from "$lib/utils";
import ReportButton from "../ReportButton.svelte";
@ -55,7 +54,7 @@
};
const copyShortURL = async () => {
const url = `${env.PUBLIC_SHORT_BASE}/${data.sid}`;
const url = `${PUBLIC_SHORT_BASE}/${data.sid}`;
await navigator.clipboard.writeText(url);
addToast({ body: "Copied the short link to your clipboard!", duration: 2000 });
};
@ -161,7 +160,7 @@
<Button color="secondary" outline on:click={copyURL}>
<Icon name="clipboard" /> Copy link
</Button>
{#if env.PUBLIC_SHORT_BASE}
{#if PUBLIC_SHORT_BASE}
<IconButton
outline
icon="link-45deg"

View file

@ -31,7 +31,7 @@
import { DateTime } from "luxon";
import { encode } from "base64-arraybuffer";
import prettyBytes from "pretty-bytes";
import { env } from "$env/dynamic/public";
import { PUBLIC_SHORT_BASE } from "$env/static/public";
import { apiFetchClient, fastFetchClient } from "$lib/api/fetch";
import IconButton from "$lib/components/IconButton.svelte";
import EditableField from "../../EditableField.svelte";
@ -392,7 +392,7 @@
};
const copyShortURL = async () => {
const url = `${env.PUBLIC_SHORT_BASE}/${data.member.sid}`;
const url = `${PUBLIC_SHORT_BASE}/${data.member.sid}`;
await navigator.clipboard.writeText(url);
addToast({ body: "Copied the short link to your clipboard!", duration: 2000 });
};
@ -779,7 +779,7 @@
</strong>
</p>
</div>
{#if env.PUBLIC_SHORT_BASE}
{#if PUBLIC_SHORT_BASE}
<div class="col-md">
<p>
Current short ID: <code>{data.member.sid}</code>

View file

@ -30,7 +30,7 @@
import { encode } from "base64-arraybuffer";
import { DateTime } from "luxon";
import { apiFetchClient } from "$lib/api/fetch";
import { env } from "$env/dynamic/public";
import { PUBLIC_SHORT_BASE } from "$env/static/public";
import IconButton from "$lib/components/IconButton.svelte";
import EditableField from "../EditableField.svelte";
import EditableName from "../EditableName.svelte";
@ -398,7 +398,7 @@
};
const copyShortURL = async () => {
const url = `${env.PUBLIC_SHORT_BASE}/${data.user.sid}`;
const url = `${PUBLIC_SHORT_BASE}/${data.user.sid}`;
await navigator.clipboard.writeText(url);
addToast({ body: "Copied the short link to your clipboard!", duration: 2000 });
};
@ -745,7 +745,7 @@
will be used.
</p>
</FormGroup>
{#if env.PUBLIC_SHORT_BASE}
{#if PUBLIC_SHORT_BASE}
<hr />
<p>
Current short ID: <code>{data.user.sid}</code>