if someone joins with invite link, skip "gateways" page

This commit is contained in:
AtHeartEngineer
2024-06-27 22:08:42 -04:00
parent d9a0d682ee
commit 433cfd80fc
3 changed files with 26 additions and 16 deletions

View File

@@ -3,6 +3,7 @@
import { alertQueue, configStore } from '$lib/stores'; import { alertQueue, configStore } from '$lib/stores';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import Loading from '$lib/components/Utils/Loading.svelte'; import Loading from '$lib/components/Utils/Loading.svelte';
import { goto } from '$app/navigation';
export let code = ''; export let code = '';
export let buttonText = 'Submit'; export let buttonText = 'Submit';
export let hideInput = false; export let hideInput = false;
@@ -11,20 +12,25 @@
let loading = false; let loading = false;
let err: string | undefined; let err: string | undefined;
function addCode(code: string) { function addCode(code: string): Promise<boolean> {
loading = true; loading = true;
inviteCode(code) return inviteCode(code)
.then((acceptedRoomNames) => { .then((acceptedRoomNames) => {
if (acceptedRoomNames) { if (acceptedRoomNames) {
acceptedRoomNames = acceptedRoomNames; acceptedRoomNames = acceptedRoomNames;
return true;
} else {
return false;
} }
}) })
.catch((err) => { .catch((err) => {
console.warn(err); console.warn(err);
alertQueue.enqueue(`Unexpected error: ${err.message}`, 'error'); alertQueue.enqueue(`Unexpected error: ${err.message}`, 'error');
return false;
}) })
.finally(() => { .finally(() => {
loading = false; loading = false;
return false;
}); });
} }
@@ -82,7 +88,11 @@
} }
onMount(() => { onMount(() => {
if (code == $configStore.signUpStatus.inviteCode && code.length >= 7) { if (code == $configStore.signUpStatus.inviteCode && code.length >= 7) {
addCode(code); addCode(code).then((accepted: boolean) => {
if (accepted) {
goto('/chat');
}
});
} }
}); });
</script> </script>

View File

@@ -7,6 +7,7 @@
import Card from '$lib/components/Utils/Card.svelte'; import Card from '$lib/components/Utils/Card.svelte';
import BullHorn from 'svelte-material-icons/Bullhorn.svelte'; import BullHorn from 'svelte-material-icons/Bullhorn.svelte';
import { configStore, numberServers } from '$lib/stores'; import { configStore, numberServers } from '$lib/stores';
import Button from '../Utils/Button.svelte';
</script> </script>
{#if $numberServers > 1} {#if $numberServers > 1}
@@ -17,8 +18,12 @@
{/if} {/if}
<div <div
id="gateway-cards" id="gateway-cards"
class="grid" class="grid">
> <!-- <Button
cls="variant-filled-success"
link="/chat"
>Lets Go Chat Anon ►
</Button> -->
<Card> <Card>
<svelte:fragment slot="header">Join via invite code</svelte:fragment> <svelte:fragment slot="header">Join via invite code</svelte:fragment>
<svelte:fragment slot="description">If you were given an invite code, you can</svelte:fragment> <svelte:fragment slot="description">If you were given an invite code, you can</svelte:fragment>
@@ -27,13 +32,11 @@
<Card> <Card>
<svelte:fragment slot="header">Join Alpha Testers</svelte:fragment> <svelte:fragment slot="header">Join Alpha Testers</svelte:fragment>
<svelte:fragment slot="description" <svelte:fragment slot="description"
>Test things out, let us know if you have any issues</svelte:fragment >Test things out, let us know if you have any issues</svelte:fragment>
>
<InviteCodeGateway <InviteCodeGateway
code={'layer-spot-gravity-fossil'} code={'layer-spot-gravity-fossil'}
hideInput={true} hideInput={true}
buttonText="Join Alpha Testers" buttonText="Join Alpha Testers" />
/>
</Card> </Card>
<Card> <Card>
<svelte:fragment slot="header">Discord Bot</svelte:fragment> <svelte:fragment slot="header">Discord Bot</svelte:fragment>
@@ -41,14 +44,12 @@
<a <a
target="_blank" target="_blank"
href="https://discord.com/api/oauth2/authorize?client_id=1142162852132700200&permissions=2147483648&scope=bot" href="https://discord.com/api/oauth2/authorize?client_id=1142162852132700200&permissions=2147483648&scope=bot"
class="btn variant-ghost-primary">Invite Discord Bot!</a class="btn variant-ghost-primary">Invite Discord Bot!</a>
>
</Card> </Card>
<Card> <Card>
<svelte:fragment slot="header">Join via Jubmoji</svelte:fragment> <svelte:fragment slot="header">Join via Jubmoji</svelte:fragment>
<svelte:fragment slot="description" <svelte:fragment slot="description"
>Prove your collection and get access to special rooms</svelte:fragment >Prove your collection and get access to special rooms</svelte:fragment>
>
<JubmojiGateway /> <JubmojiGateway />
</Card> </Card>
<Card> <Card>
@@ -64,8 +65,7 @@
</Card> </Card>
<Card> <Card>
<svelte:fragment slot="header" <svelte:fragment slot="header"
><span class="flex gap-3">The Word <BullHorn /></span></svelte:fragment ><span class="flex gap-3">The Word <BullHorn /></span></svelte:fragment>
>
<svelte:fragment slot="description" <svelte:fragment slot="description"
>Do you know <a >Do you know <a
class="link" class="link"

View File

@@ -72,7 +72,7 @@
on:complete={() => { on:complete={() => {
goto('/chat'); goto('/chat');
}} }}
buttonCompleteLabel="Lets Go Chat Anon" buttonCompleteLabel="Lets Go Chat Anon "
buttonNext="variant-filled-success" buttonNext="variant-filled-success"
buttonComplete="variant-filled-success"> buttonComplete="variant-filled-success">
<Step class="px-10"> <Step class="px-10">