Skip to content

Commit 34c009c

Browse files
committed
add error and with site
1 parent 639ef8d commit 34c009c

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

Diff for: .firebaserc

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
"targets": {
66
"ccd-firebase-app-check": {
77
"hosting": {
8+
"default": [
9+
"ccd-firebase-app-check-not"
10+
],
811
"with": [
9-
"ccd-firebase-app-check"
12+
"ccd-firebase-app-check-with"
1013
],
1114
"without": [
1215
"ccd-firebase-app-check-without"

Diff for: firebase.json

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
"indexes": "firestore.indexes.json"
55
},
66
"hosting": [
7+
{
8+
"target": "default",
9+
"public": "dist",
10+
"ignore": [
11+
"firebase.json",
12+
"**/.*",
13+
"**/node_modules/**"
14+
],
15+
"rewrites": [
16+
{
17+
"source": "**",
18+
"destination": "/index.html"
19+
}
20+
]
21+
},
722
{
823
"target": "with",
924
"public": "dist",

Diff for: src/lib/CounterReader.svelte

+22-8
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
const q = query(collection(db, "counts"), orderBy("date", "desc"), limit(5));
1717
1818
$: counts = [];
19-
20-
const unsubscribe = onSnapshot(q, (querySnapshot) => {
21-
const allCounts = [];
22-
querySnapshot.forEach((doc) => {
23-
allCounts.push({ id: doc.id, ...doc.data() });
24-
});
25-
counts = allCounts;
26-
});
19+
$: error = "";
20+
const unsubscribe = onSnapshot(
21+
q,
22+
(querySnapshot) => {
23+
const allCounts = [];
24+
querySnapshot.forEach((doc) => {
25+
allCounts.push({ id: doc.id, ...doc.data() });
26+
});
27+
counts = allCounts;
28+
},
29+
(e) => (error = e.message)
30+
);
2731
2832
onDestroy(() => {
2933
unsubscribe();
@@ -44,6 +48,11 @@
4448
<div><span>Count: </span><span>{count.count}</span></div>
4549
</div>
4650
{/each}
51+
{#if error}
52+
<div class="error">
53+
{error}
54+
</div>
55+
{/if}
4756
</section>
4857

4958
<style>
@@ -67,4 +76,9 @@
6776
font-family: inherit;
6877
background-color: #2f2f2f;
6978
}
79+
.error {
80+
background-color: red;
81+
font-size: 2rem;
82+
padding: 1rem;
83+
}
7084
</style>

0 commit comments

Comments
 (0)