Skip to content

Commit

Permalink
fixing behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Jun 17, 2024
1 parent dc8324a commit f1ac9b5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
3 changes: 0 additions & 3 deletions src/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script lang="ts">
import type { LayoutServerData } from '$types';
export const data: LayoutServerData = undefined;
</script>

<footer
Expand Down
14 changes: 8 additions & 6 deletions src/components/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
<script lang="ts">
import type { PageData } from '$types';
import { Hamburger } from 'svelte-hamburgers';
import { Button } from '$components/ui/button';
import Sun from 'lucide-svelte/icons/sun';
import Moon from 'lucide-svelte/icons/moon';
import { toggleMode } from 'mode-watcher';
export let data: PageData;
export let authChange: boolean;
let { supabase } = data;
let { supabase, authChange = $bindable() }: { supabase: any; authChange: Boolean } = $props();
let open: boolean = true;
let currentUser: { data: { user: { aud: string } } };
let currentUser: { data: { user: { aud: string } } } | undefined = $state();
async function getCurrentUser() {
return await supabase.auth.getUser().then((res: { data: { user: { aud: string } } }) => {
currentUser = res;
});
}
$: authChange, getCurrentUser();
$effect(() => {
authChange;
getCurrentUser();
});
</script>

<div class="absolute end-0">
Expand Down
1 change: 1 addition & 0 deletions src/components/Matches.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import type { RealtimeChannel } from '@supabase/supabase-js';
import { Alert, Button } from 'flowbite-svelte';
import type { HttpError } from '@sveltejs/kit';
import type { Teams } from '$lib/teams.svelte';
let {
matches = $bindable(),
Expand Down
2 changes: 2 additions & 0 deletions src/lib/event.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class Event extends Base {

this.databaseService = databaseService;
this.id = event_id;

if (this.id !== 'create') this.load();
}

/**
Expand Down
15 changes: 8 additions & 7 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { goto, invalidate } from '$app/navigation';
import { ModeWatcher } from 'mode-watcher';
import { onMount } from 'svelte';
import type { LayoutData } from './$types';
import { SvelteToast } from '@zerodevx/svelte-toast';
import type { SvelteToastOptions } from '@zerodevx/svelte-toast/stores';
import { dev } from '$app/environment';
Expand All @@ -14,12 +13,13 @@
inject({ mode: dev ? 'development' : 'production' });
export let data: LayoutData;
$: ({ session, supabase } = data);
let { data, authChange } = $props();
let { session, supabase } = data;
let authChange = false;
onMount(() => {
const { data } = supabase.auth.onAuthStateChange((_, newSession) => {
const { data } = supabase.auth.onAuthStateChange((_: any, newSession: { expires_at: any }) => {
authChange = !authChange;
if (!newSession) {
/**
* Queue this as a task so the navigation won't prevent the
Expand Down Expand Up @@ -51,7 +51,8 @@

<div class="dark:bg-gray-900 dark:text-gray-100 text-gray-900 bg-white">
<ModeWatcher defaultMode={'light'} />
<Header {data} {authChange} />

<Header {supabase} bind:authChange />

<div class="min-h-screen">
<div class="wrap">
Expand All @@ -60,5 +61,5 @@
<slot {data} />
</div>

<Footer {data} />
<Footer />
</div>
7 changes: 5 additions & 2 deletions src/routes/protected-routes/events/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { Modal } from 'flowbite-svelte';
import { initiateEvent } from '$lib/helper';
export let data: PageData;
let { data } = $props();
let { supabase, event_id, form } = data;
let { tournament, matches, teams, bracket } = initiateEvent(event_id, supabase);
Expand All @@ -41,7 +41,10 @@
}
}
$: $page.state.eventCreated, reloadEventInstances();
$effect(() => {
$page.state.eventCreated;
reloadEventInstances();
});
const loadingInitialDataPromise = loadInitialData(tournament, matches, teams, bracket);
Expand Down

0 comments on commit f1ac9b5

Please sign in to comment.