Don't load onSnapshot from cache in hook listen for contract (could help 404 errors?)
This commit is contained in:
parent
967ac1b08d
commit
ac9af1acd6
|
@ -17,7 +17,7 @@ import {
|
|||
import _ from 'lodash'
|
||||
|
||||
import { app } from './init'
|
||||
import { getValues, listenForValues } from './utils'
|
||||
import { getValues, listenForValue, listenForValues } from './utils'
|
||||
import { Contract } from '../../../common/contract'
|
||||
import { getProbability } from '../../../common/calculate'
|
||||
import { createRNG, shuffle } from '../../../common/util/random'
|
||||
|
@ -125,9 +125,7 @@ export function listenForContract(
|
|||
setContract: (contract: Contract | null) => void
|
||||
) {
|
||||
const contractRef = doc(contractCollection, contractId)
|
||||
return onSnapshot(contractRef, (contractSnap) => {
|
||||
setContract((contractSnap.data() ?? null) as Contract | null)
|
||||
})
|
||||
return listenForValue<Contract>(contractRef, setContract)
|
||||
}
|
||||
|
||||
function chooseRandomSubset(contracts: Contract[], count: number) {
|
||||
|
|
|
@ -23,6 +23,8 @@ export function listenForValue<T>(
|
|||
setValue: (value: T | null) => void
|
||||
) {
|
||||
return onSnapshot(docRef, (snapshot) => {
|
||||
if (snapshot.metadata.fromCache) return
|
||||
|
||||
const value = snapshot.exists() ? (snapshot.data() as T) : null
|
||||
setValue(value)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user