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:
Paul Frazee
2023-11-15 17:17:50 -08:00
committed by GitHub
parent f23e9978d8
commit 6616b2bff0
20 changed files with 186 additions and 136 deletions
+20
View File
@@ -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)
}