Kill warmup spam (#133)
* Only warm up sell bet function once * Only warm up create user function once
This commit is contained in:
parent
adefd3259c
commit
2e214cab7a
|
@ -553,10 +553,11 @@ function BetRow(props: { bet: Bet; contract: Contract; saleBet?: Bet }) {
|
|||
)
|
||||
}
|
||||
|
||||
const warmUpSellBet = _.throttle(() => sellBet({}).catch(), 5000 /* ms */)
|
||||
|
||||
function SellButton(props: { contract: Contract; bet: Bet }) {
|
||||
useEffect(() => {
|
||||
// warm up cloud function
|
||||
sellBet({}).catch()
|
||||
warmUpSellBet()
|
||||
}, [])
|
||||
|
||||
const { contract, bet } = props
|
||||
|
|
|
@ -77,11 +77,13 @@ const CACHED_USER_KEY = 'CACHED_USER_KEY'
|
|||
// used to avoid weird race condition
|
||||
let createUserPromise: Promise<User | null> | undefined = undefined
|
||||
|
||||
const warmUpCreateUser = _.throttle(createUser, 5000 /* ms */)
|
||||
|
||||
export function listenForLogin(onUser: (user: User | null) => void) {
|
||||
const cachedUser = localStorage.getItem(CACHED_USER_KEY)
|
||||
onUser(cachedUser ? JSON.parse(cachedUser) : null)
|
||||
|
||||
if (!cachedUser) createUser() // warm up cloud function
|
||||
if (!cachedUser) warmUpCreateUser()
|
||||
|
||||
return onAuthStateChanged(auth, async (fbUser) => {
|
||||
if (fbUser) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user