Skip to content

Commit

Permalink
fix: sec rule update
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLinCool committed Dec 26, 2024
1 parent d25be06 commit 3911202
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions src/routes/dashboard/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onDestroy } from 'svelte';
import { onDestroy, onMount } from 'svelte';
import { writable, derived } from 'svelte/store';
import { Card, Button } from 'flowbite-svelte';
import { MessageSquarePlus, UserPlus, UserCog, GitFork } from 'lucide-svelte';
Expand All @@ -11,11 +11,9 @@
where,
Timestamp,
collectionGroup,
doc,
getDoc,
getDocs
} from 'firebase/firestore';
import { user } from '$lib/stores/auth';
import { profile } from '$lib/stores/profile';
import { db } from '$lib/firebase';
import { subscribeAll } from '$lib/firebase/store';
Expand All @@ -24,37 +22,46 @@
import { goto } from '$app/navigation';
import { createTemplate } from './createTemplate';
import { notifications } from '$lib/stores/notifications';
import { browser } from '$app/environment';
import { user } from '$lib/stores/auth';
import { getUser } from '$lib/utils/getUser';
let { data } = $props();
// Query for user's templates
let [templates, { unsubscribe: unsubscribe1 }] = subscribeAll<Template>(
query(
collection(db, 'templates'),
where('owner', '==', data.user.uid),
orderBy('createdAt', 'desc'),
limit(6)
)
);
let [templates, { unsubscribe: unsubscribe1 }] = browser
? subscribeAll<Template>(
query(
collection(db, 'templates'),
where('owner', '==', data.user.uid),
orderBy('createdAt', 'desc'),
limit(6)
)
)
: [null, { unsubscribe: () => {} }];
// Query for public templates
let [publicTemplates, { unsubscribe: unsubscribe2 }] = subscribeAll<Template>(
query(
collection(db, 'templates'),
where('public', '==', true),
orderBy('createdAt', 'desc'),
limit(6)
)
);
let [publicTemplates, { unsubscribe: unsubscribe2 }] = browser
? subscribeAll<Template>(
query(
collection(db, 'templates'),
where('public', '==', true),
orderBy('createdAt', 'desc'),
limit(6)
)
)
: [null, { unsubscribe: () => {} }];
let [hostSessions, { unsubscribe: unsubscribe3 }] = subscribeAll<Session>(
query(
collection(db, 'sessions'),
where('host', '==', data.user.uid),
orderBy('createdAt', 'desc'),
limit(6)
)
);
let [hostSessions, { unsubscribe: unsubscribe3 }] = browser
? subscribeAll<Session>(
query(
collection(db, 'sessions'),
where('host', '==', data.user.uid),
orderBy('createdAt', 'desc'),
limit(6)
)
)
: [null, { unsubscribe: () => {} }];
let unsoredsessions = writable<[string, string, Session][]>([]);
Expand All @@ -73,21 +80,16 @@
const sessionSnapshot = await getDocs(sessionQuery);
sessionSnapshot.forEach(async (docu) => {
const session = await getDoc(docu.ref.parent.parent!);
const host = await getDoc(doc(db, 'profiles', session.data()?.host));
let hoster = '';
if (!host.exists()) {
hoster = 'Unknown';
} else {
hoster = host.data()?.displayName;
}
unsoredsessions.update((value) => [
...value,
[hoster, session.id, session.data() as Session]
]);
const sessionData = session.data();
const host = await getUser(sessionData?.host);
const hoster = host.displayName;
unsoredsessions.update((value) => [...value, [hoster, session.id, sessionData as Session]]);
});
}
getSessions();
onMount(() => {
getSessions();
});
async function handleCreateTemplate() {
try {
Expand Down

0 comments on commit 3911202

Please sign in to comment.