Skip to content

Commit

Permalink
Merge pull request #51 from hinagiku-dev/New-code
Browse files Browse the repository at this point in the history
Update HostView.svelte
  • Loading branch information
180079995 authored Dec 22, 2024
2 parents c6347bc + 3adcd40 commit fcf13d5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/components/session/HostView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Alert } from 'flowbite-svelte';
import type { Group } from '$lib/schema/group';
import { onMount } from 'svelte';
import { collection, getDocs, onSnapshot } from 'firebase/firestore';
import { collection, getDocs, onSnapshot, getDoc, doc } from 'firebase/firestore';
import { db } from '$lib/firebase';
import { writable } from 'svelte/store';
import { getUser } from '$lib/utils/getUser';
Expand All @@ -20,6 +20,7 @@
import { X } from 'lucide-svelte';
let { session }: { session: Readable<Session> } = $props();
let code = $state('Code generate error');
type GroupWithId = Group & { id: string };
let groups = writable<GroupWithId[]>([]);
let participantNames = $state(new Map<string, string>());
Expand All @@ -44,6 +45,9 @@
onMount(() => {
const initializeSession = async () => {
try {
const codeCollection = doc(db, 'temp_codes', $page.params.id);
const codeDoc = await getDoc(codeCollection);
code = codeDoc.data()?.code;
const groupsCollection = collection(db, `sessions/${$page.params.id}/groups`);
const unsubscribe = onSnapshot(groupsCollection, (snapshot) => {
const groupsData: GroupWithId[] = snapshot.docs.map(
Expand Down Expand Up @@ -273,6 +277,10 @@
<h3 class="mb-2 font-medium">Session QR Code</h3>
<QRCode value={`${$page.url.origin}/session/${$page.params.id}`} />
</div>
<div class="mt-4">
<h3 class="mb-2 font-medium">Session Code</h3>
<p class="text-blue-700">{code}</p>
</div>
{/if}
</div>
{/if}
Expand Down

0 comments on commit fcf13d5

Please sign in to comment.