Skip to content

Commit

Permalink
chore: fix issues with cancelling own scrim
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsMeBrianD committed Dec 20, 2024
1 parent 5b7487a commit db6536d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions clients/web/src/routes/(app)/org-manager/scrims/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
$: ({ ScrimManagementPage } = data);
onMount(() => {
ScrimManagementPage.fetch();
})
$: groupedScrims = groupBy($ScrimManagementPage?.data?.allScrims ?? [], (s) => s.game.name);
const manageScrimsHydrator = new ManageScrimsHydrationStore();
manageScrimsHydrator.listen();
Expand Down
2 changes: 2 additions & 0 deletions clients/web/src/routes/(app)/scrims/+page.gql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ query ScrimPageRoot {
...ScrimFlow_Fragment
id
state
complete
}
pendingScrims @list(name: "ScrimPage_PendingScrims") {
...ScrimList_Fragment
Expand All @@ -16,5 +17,6 @@ query ScrimPageRoot {
checkedIn
}
participantCount
complete
}
}
21 changes: 17 additions & 4 deletions clients/web/src/routes/(app)/scrims/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<script lang="ts">
import { PendingScrimHydrationStore, CurrentScrimHydrationStore, cache } from '$houdini';
import { onMount } from 'svelte';
import type { PageData } from './$houdini';
import ScrimFlow from './ScrimFlow.svelte';
import ScrimList from './ScrimList.svelte';
export let data: PageData;
$: ({ ScrimPageRoot } = data);
const pendingScrimsHydration = new PendingScrimHydrationStore();
pendingScrimsHydration.listen();
const currentScrimHydration = new CurrentScrimHydrationStore();
$: if ($pendingScrimsHydration.data) {
const scrimCache = cache.get('Scrim', $pendingScrimsHydration.data.live);
if (scrimCache && $pendingScrimsHydration.data.live.complete) {
Expand All @@ -17,16 +20,26 @@
cache.list('ScrimPage_PendingScrims').append(scrimCache);
}
}
new CurrentScrimHydrationStore().listen();
</script>
onMount(() => {
currentScrimHydration.listen();
pendingScrimsHydration.listen();
return () => {
currentScrimHydration.unlisten()
currentScrimHydration.unlisten()
}
})
</script>

{#if !$ScrimPageRoot.data}
Loading...
{:else if !$ScrimPageRoot.data.whoami.players.length}
<section class="card p-4 col-span-full">
<p class="text-xl font-bold text-center">You are not registered as a player for any games, and cannot scrim.</p>
</section>
{:else if $ScrimPageRoot.data?.currentScrim}
{:else if $ScrimPageRoot.data?.currentScrim && !$ScrimPageRoot.data.currentScrim.complete}
<!-- User is currently in a scrim -->
<ScrimFlow
pendingScrims={$ScrimPageRoot.data.pendingScrims}
Expand Down
5 changes: 4 additions & 1 deletion clients/web/src/routes/(app)/scrims/ScrimList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
Create Scrim
</button>
</header>
{#each pendingScrims ?? [] as scrim}
{#each pendingScrims?.filter(p => {
console.log(Object.keys(p))
return !p.complete
}) ?? [] as scrim}
<ScrimListItem pendingScrim={scrim} />
{:else}
There are currently no active scrims
Expand Down
5 changes: 0 additions & 5 deletions clients/web/src/routes/(app)/scrims/ScrimListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@
<p>Current Participants: {$scrim.participantCount} / {$scrim.gameMode.playerCount}</p>
<p>State: {$scrim.state}</p>
</SubjectBox>
<div>
<p>ScrimId: {$scrim.id}</p>
<p>ParticipantCount: {$scrim.participantCount}</p>
<p>ParticipantCount: {$scrim.participantCount}</p>
</div>
{/if}

0 comments on commit db6536d

Please sign in to comment.