Remove dead code
This commit is contained in:
parent
405c77a6ce
commit
b06b424f09
|
@ -1,10 +1,8 @@
|
||||||
import { useFirestoreQueryData } from '@react-query-firebase/firestore'
|
import { useFirestoreQueryData } from '@react-query-firebase/firestore'
|
||||||
import { isEqual } from 'lodash'
|
import { useEffect, useState } from 'react'
|
||||||
import { useEffect, useRef, useState } from 'react'
|
|
||||||
import {
|
import {
|
||||||
Contract,
|
Contract,
|
||||||
listenForActiveContracts,
|
listenForActiveContracts,
|
||||||
listenForContract,
|
|
||||||
listenForContracts,
|
listenForContracts,
|
||||||
listenForHotContracts,
|
listenForHotContracts,
|
||||||
listenForInactiveContracts,
|
listenForInactiveContracts,
|
||||||
|
@ -62,39 +60,6 @@ export const useHotContracts = () => {
|
||||||
return hotContracts
|
return hotContracts
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUpdatedContracts = (contracts: Contract[] | undefined) => {
|
|
||||||
const [__, triggerUpdate] = useState(0)
|
|
||||||
const contractDict = useRef<{ [id: string]: Contract }>({})
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (contracts === undefined) return
|
|
||||||
|
|
||||||
contractDict.current = Object.fromEntries(contracts.map((c) => [c.id, c]))
|
|
||||||
|
|
||||||
const disposes = contracts.map((contract) => {
|
|
||||||
const { id } = contract
|
|
||||||
|
|
||||||
return listenForContract(id, (contract) => {
|
|
||||||
const curr = contractDict.current[id]
|
|
||||||
if (!isEqual(curr, contract)) {
|
|
||||||
contractDict.current[id] = contract as Contract
|
|
||||||
triggerUpdate((n) => n + 1)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
triggerUpdate((n) => n + 1)
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
disposes.forEach((dispose) => dispose())
|
|
||||||
}
|
|
||||||
}, [!!contracts])
|
|
||||||
|
|
||||||
return contracts && Object.keys(contractDict.current).length > 0
|
|
||||||
? contracts.map((c) => contractDict.current[c.id])
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
export const usePrefetchUserBetContracts = (userId: string) => {
|
export const usePrefetchUserBetContracts = (userId: string) => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return queryClient.prefetchQuery(
|
return queryClient.prefetchQuery(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user