Empty msg fix, unread after opening msg fix

This commit is contained in:
mrfry 2022-05-12 19:52:49 +02:00
parent 02954e0d01
commit 98164ff4fa
2 changed files with 13 additions and 15 deletions

View file

@ -7,7 +7,7 @@ import Layout from '../components/layout'
import '../defaultStyles.css'
import constants from '../constants.json'
const queryClient = new QueryClient({
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
@ -44,20 +44,12 @@ const getGlobalProps = () => {
}
function App({ Component, pageProps, router }) {
const [userId, setUserId] = useState()
const [motd, setMotd] = useState()
const [unreads, setUnreads] = useState()
const [globalState, setGlobalState] = useState({})
const { data } = useQuery('hasNewMsgs', () => getGlobalProps(), {
const { data } = useQuery(['infos'], () => getGlobalProps(), {
refetchOnWindowFocus: true,
})
useEffect(() => {
if (!data) return
setUserId(data.uid)
setMotd(data.motd)
setUnreads(data.unreads)
}, [data])
const { motd, uid: userId, unreads } = data || {}
useEffect(() => {
getGlobalProps()