From bfee2ea954122dfe1c82eee41d1d40f0facaf0ca Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 1 Mar 2022 18:45:07 -0800 Subject: [PATCH] Fix bug where listen query was not updating data. --- web/lib/firebase/utils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/lib/firebase/utils.ts b/web/lib/firebase/utils.ts index b6174d48..39f93408 100644 --- a/web/lib/firebase/utils.ts +++ b/web/lib/firebase/utils.ts @@ -1,6 +1,5 @@ import { db } from './init' import { - doc, getDoc, getDocs, onSnapshot, @@ -22,7 +21,7 @@ export function listenForValue( docRef: DocumentReference, setValue: (value: T | null) => void ) { - return onSnapshot(docRef, (snapshot) => { + return onSnapshot(docRef, { includeMetadataChanges: true }, (snapshot) => { if (snapshot.metadata.fromCache) return const value = snapshot.exists() ? (snapshot.data() as T) : null @@ -34,7 +33,7 @@ export function listenForValues( query: Query, setValues: (values: T[]) => void ) { - return onSnapshot(query, (snapshot) => { + return onSnapshot(query, { includeMetadataChanges: true }, (snapshot) => { if (snapshot.metadata.fromCache) return const values = snapshot.docs.map((doc) => doc.data() as T)