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
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
4 changed files with 12 additions and 14 deletions

View file

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

View file

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

View file

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

View file

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