Shell behaviors update (react-query refactor) (#1915)
* Move tick-every-minute into a hook/context * Move soft-reset event out of the shell model * Update soft-reset listener on new search page * Implement session-loaded and session-dropped events * Update analytics and push-notifications to use new session system
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import React from 'react'
|
||||
|
||||
type StateContext = number
|
||||
|
||||
const stateContext = React.createContext<StateContext>(0)
|
||||
|
||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
const [tick, setTick] = React.useState(Date.now())
|
||||
React.useEffect(() => {
|
||||
const i = setInterval(() => {
|
||||
setTick(Date.now())
|
||||
}, 60_000)
|
||||
return () => clearInterval(i)
|
||||
}, [])
|
||||
return <stateContext.Provider value={tick}>{children}</stateContext.Provider>
|
||||
}
|
||||
|
||||
export function useTickEveryMinute() {
|
||||
return React.useContext(stateContext)
|
||||
}
|
||||
Reference in New Issue
Block a user