fix(dashboard): fix crash when opening dash while not logged in

This commit is contained in:
Draconizations 2022-05-30 13:00:57 +02:00
parent 0a048cdc32
commit 0d774a7c9e
3 changed files with 16 additions and 5 deletions

View File

@ -1,11 +1,14 @@
<script lang="ts"> <script lang="ts">
import { Container, Row, Col, Card, CardHeader, CardBody, CardTitle, Alert, Label, Input, Button, Spinner } from 'sveltestrap'; import { Container, Row, Col, Card, CardHeader, CardBody, CardTitle, Alert, Label, Input, Button, Spinner } from 'sveltestrap';
import { navigate } from 'svelte-navigator';
import FaUserLock from 'svelte-icons/fa/FaUserLock.svelte'; import FaUserLock from 'svelte-icons/fa/FaUserLock.svelte';
import api from '../api'; import api from '../api';
import { GroupPrivacy, System } from '../api/types'; import { GroupPrivacy, System } from '../api/types';
const user: System = JSON.parse(localStorage.getItem("pk-user")); const user: System = JSON.parse(localStorage.getItem("pk-user"));
if (!user) navigate('/');
// const capitalize = (str: string) => str[0].toUpperCase() + str.substr(1); // const capitalize = (str: string) => str[0].toUpperCase() + str.substr(1);
let loading = false; let loading = false;
@ -52,6 +55,7 @@
} }
</script> </script>
{#if user}
<Container> <Container>
<Row> <Row>
<Col class="mx-auto" xs={12} lg={11} xl={10}> <Col class="mx-auto" xs={12} lg={11} xl={10}>
@ -102,3 +106,4 @@
</Col> </Col>
</Row> </Row>
</Container> </Container>
{/if}

View File

@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import { Container, Row, Col, Card, CardHeader, CardBody, CardTitle, Label, Input, Button, Spinner, Alert } from 'sveltestrap'; import { Container, Row, Col, Card, CardHeader, CardBody, CardTitle, Label, Input, Button, Spinner, Alert } from 'sveltestrap';
import { navigate } from 'svelte-navigator';
import FaUserLock from 'svelte-icons/fa/FaUserLock.svelte'; import FaUserLock from 'svelte-icons/fa/FaUserLock.svelte';
import api from '../api'; import api from '../api';
import { MemberPrivacy, System } from '../api/types'; import { MemberPrivacy, System } from '../api/types';
import Member from './Member.svelte';
const user: System = JSON.parse(localStorage.getItem("pk-user")); const user: System = JSON.parse(localStorage.getItem("pk-user"));
if (!user) navigate('/');
// const capitalize = (str: string) => str[0].toUpperCase() + str.substr(1); // const capitalize = (str: string) => str[0].toUpperCase() + str.substr(1);
let loading = false; let loading = false;
@ -54,6 +56,7 @@ import Member from './Member.svelte';
} }
</script> </script>
{#if user}
<Container> <Container>
<Row> <Row>
<Col class="mx-auto" xs={12} lg={11} xl={10}> <Col class="mx-auto" xs={12} lg={11} xl={10}>
@ -104,3 +107,4 @@ import Member from './Member.svelte';
</Col> </Col>
</Row> </Row>
</Container> </Container>
{/if}

View File

@ -75,6 +75,7 @@
{#if user && user.banner && ((settings && settings.appearance.banner_top) || !settings)} {#if user && user.banner && ((settings && settings.appearance.banner_top) || !settings)}
<div class="banner" style="background-image: url({user.banner})" /> <div class="banner" style="background-image: url({user.banner})" />
{/if} {/if}
{#if user}
<Container> <Container>
<Row> <Row>
<Col class="mx-auto" xs={12} lg={11} xl={10}> <Col class="mx-auto" xs={12} lg={11} xl={10}>
@ -93,6 +94,7 @@
</Col> </Col>
</Row> </Row>
</Container> </Container>
{/if}
<svelte:head> <svelte:head>
<title>PluralKit | dash</title> <title>PluralKit | dash</title>