attempt to fix lastChecked getting overwritten
This commit is contained in:
parent
1f466970b3
commit
1d154ec9b5
|
@ -516,8 +516,15 @@ export default function Notifications ({ ssrData }) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const dat = useData(data, ssrData)
|
const dat = useData(data, ssrData)
|
||||||
|
|
||||||
const { notifications: { notifications, lastChecked, cursor } } = useMemo(() => {
|
const { notifications, lastChecked, cursor } = useMemo(() => {
|
||||||
return dat || { notifications: {} }
|
if (!dat?.notifications) return {}
|
||||||
|
|
||||||
|
// make sure we're using the oldest lastChecked we've seen
|
||||||
|
const retDat = { ...dat.notifications }
|
||||||
|
if (ssrData?.notifications?.lastChecked < retDat.lastChecked) {
|
||||||
|
retDat.lastChecked = ssrData.notifications.lastChecked
|
||||||
|
}
|
||||||
|
return retDat
|
||||||
}, [dat])
|
}, [dat])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -29,10 +29,6 @@ function getClient (uri) {
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
link: new HttpLink({ uri }),
|
link: new HttpLink({ uri }),
|
||||||
ssrMode: SSR,
|
ssrMode: SSR,
|
||||||
// we need to delay the cache-first check to wait for the cache to rehydrate from ssr
|
|
||||||
// occasionally, for queries like notifications, the cache is not populated when useQuery
|
|
||||||
// is called causing an additional network request
|
|
||||||
ssrForceFetchDelay: 250,
|
|
||||||
connectToDevTools: process.env.NODE_ENV !== 'production',
|
connectToDevTools: process.env.NODE_ENV !== 'production',
|
||||||
cache: new InMemoryCache({
|
cache: new InMemoryCache({
|
||||||
freezeResults: true,
|
freezeResults: true,
|
||||||
|
@ -224,6 +220,7 @@ function getClient (uri) {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
assumeImmutableResults: true,
|
assumeImmutableResults: true,
|
||||||
|
queryDeduplication: true,
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
watchQuery: {
|
watchQuery: {
|
||||||
initialFetchPolicy: defaultFetchPolicy,
|
initialFetchPolicy: defaultFetchPolicy,
|
||||||
|
|
Loading…
Reference in New Issue