Skip to content

Commit 6df55c2

Browse files
committed
Add user share code links!
1 parent 706f2b6 commit 6df55c2

File tree

6 files changed

+36
-7
lines changed

6 files changed

+36
-7
lines changed

.github/workflows/ci-build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,4 @@ jobs:
6666
registry-path: ${{ github.repository_owner }}/frontend
6767
registry-username: ${{ github.actor }}
6868
registry-password: ${{ secrets.GITHUB_TOKEN }}
69-
artifact-name: frontend
7069
push-image: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && (github.ref_name == 'master' || github.ref_name == 'develop') }}

src/routes/(authenticated)/shares/user/+layout.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
let createDialogOpen = $state(false);
1616
let redeemDialogOpen = $state(false);
1717
let createdCode = $state<string | null>(null);
18+
let redeemUserInput = $state<string>('');
1819
1920
let tab = $derived(() => {
2021
switch (page.url.pathname) {
@@ -45,12 +46,19 @@
4546
4647
onMount(() => {
4748
refreshOwnHubs();
49+
50+
// Check for redeem query param and redeem pop
51+
if(page.url.searchParams.has('redeem')) {
52+
const code = page.url.searchParams.get('redeem');
53+
redeemDialogOpen = true;
54+
redeemUserInput = code ?? '';
55+
}
4856
});
4957
</script>
5058

5159
<DialogShareCodeCreate bind:open={createDialogOpen} {onCreatedCode} {onInvitedUser} />
5260
<DialogShareCodeCreated bind:code={createdCode} />
53-
<DialogShareCodeRedeem bind:open={redeemDialogOpen} />
61+
<DialogShareCodeRedeem bind:open={redeemDialogOpen} bind:userInput={redeemUserInput} />
5462

5563
<div class="h-full m-8 mt-4 flex flex-col gap-4">
5664
<div class="flex-none flex w-full">

src/routes/(authenticated)/shares/user/dialog-share-code-created.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import KeyRound from '@lucide/svelte/icons/key-round';
33
import CopyInput from '$lib/components/CopyInput.svelte';
44
import * as Dialog from '$lib/components/ui/dialog';
5+
import { Link } from '@lucide/svelte';
6+
import { PUBLIC_SITE_SHORT_URL } from '$env/static/public';
57
68
interface Props {
79
code: string | null;
810
}
911
1012
let { code = $bindable() }: Props = $props();
13+
let link = $derived(() => new URL(`/usc/${code}`, PUBLIC_SITE_SHORT_URL).toString());
1114
1215
function onOpenChanged(open: boolean) {
1316
if (!open) {
@@ -20,15 +23,21 @@
2023
<Dialog.Content>
2124
<Dialog.Header>
2225
<Dialog.Title>Share Code Generated</Dialog.Title>
23-
<Dialog.Description>Please copy share code!</Dialog.Description>
26+
<Dialog.Description>Please copy share code or code link!</Dialog.Description>
2427
</Dialog.Header>
2528
<div class="flex flex-col items-center space-y-4">
26-
<div class="flex w-full items-center justify-between rounded-md p-2">
29+
<div class="flex w-full items-center justify-between rounded-md p-2 flex-col gap-2">
2730
<CopyInput value={code!}>
2831
{#snippet icon()}
2932
<KeyRound size="20" />
3033
{/snippet}
3134
</CopyInput>
35+
36+
<CopyInput value={link()}>
37+
{#snippet icon()}
38+
<Link size="20" />
39+
{/snippet}
40+
</CopyInput>
3241
</div>
3342
</div>
3443
</Dialog.Content>

src/routes/(authenticated)/shares/user/dialog-share-code-redeem.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
1414
interface Props {
1515
open: boolean;
16+
userInput: string;
1617
}
1718
18-
let { open = $bindable() }: Props = $props();
19-
let userInput = $state<string>('');
19+
let { open = $bindable(), userInput = $bindable() }: Props = $props();
2020
let redeemPromise = $state<Promise<V2UserSharesListItem> | null>(null);
2121
let redeemed = $state<boolean>(false);
2222

src/routes/usc/[code]/+server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { redirect } from '@sveltejs/kit';
2+
import { resolve } from '$app/paths';
3+
import type { RequestHandler } from './$types';
4+
5+
export const GET: RequestHandler = ({ params }) => {
6+
const location = `${resolve('/shares/user/outgoing')}?redeem=${encodeURIComponent(params.code)}`;
7+
console.log(`Redirecting to: ${location}`);
8+
throw redirect(303, location); // 303 = safe for GET and avoids caching as "permanent"
9+
};

vite.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ async function getServerConfig(mode: string, useLocalRedirect: boolean) {
8080
return { host: 'localhost', port: 8080, proxy: {} };
8181
}
8282

83-
const host = `local.${domain}`;
83+
let host = domain;
84+
85+
if(!domain.startsWith('local.')) {
86+
host = `local.${domain}`;
87+
}
8488

8589
// Ensure we have the host entry redirecting to localhost
8690
await ensureFqdnRedirect('127.0.0.1', host);

0 commit comments

Comments
 (0)