mirror of
				https://gitlab.com/MrFry/qmining-page
				synced 2025-04-01 20:23:44 +02:00 
			
		
		
		
	Added global header, refetch infos on window focus
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| import React, { useState, useEffect } from 'react' | ||||
| import React, { useState } from 'react' | ||||
| import { useQuery, QueryClientProvider, QueryClient } from 'react-query' | ||||
| import Head from 'next/head' | ||||
|  | ||||
| @@ -46,15 +46,11 @@ const getGlobalProps = () => { | ||||
| function App({ Component, pageProps, router }) { | ||||
|   const [globalState, setGlobalState] = useState({}) | ||||
|   const { data } = useQuery(['infos'], () => getGlobalProps(), { | ||||
|     refetchOnWindowFocus: true, | ||||
|     refetchOnWindowFocus: 'always', | ||||
|   }) | ||||
|  | ||||
|   const { motd, uid: userId, unreads } = data || {} | ||||
|  | ||||
|   useEffect(() => { | ||||
|     getGlobalProps() | ||||
|   }, []) | ||||
|  | ||||
|   const updateGlobalState = (newState) => { | ||||
|     setGlobalState({ | ||||
|       ...globalState, | ||||
| @@ -79,7 +75,7 @@ function App({ Component, pageProps, router }) { | ||||
|       <Layout | ||||
|         router={router} | ||||
|         globalData={globalData} | ||||
|         refetchGlobalData={getGlobalProps} | ||||
|         refetchGlobalData={() => queryClient.invalidateQueries(['infos'])} | ||||
|         setGlobalState={updateGlobalState} | ||||
|         globalState={globalState} | ||||
|       > | ||||
| @@ -87,7 +83,7 @@ function App({ Component, pageProps, router }) { | ||||
|           {...pageProps} | ||||
|           router={router} | ||||
|           globalData={globalData} | ||||
|           refetchGlobalData={getGlobalProps} | ||||
|           refetchGlobalData={() => queryClient.invalidateQueries(['infos'])} | ||||
|           setGlobalState={updateGlobalState} | ||||
|           globalState={globalState} | ||||
|         /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user