fix notifications glitchiness
This commit is contained in:
parent
42234eae9b
commit
23257d8c63
@ -42,9 +42,9 @@ function NotificationLayout ({ children, nid, href, as }) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`clickToContext ${router?.query?.nid === nid ? 'outline-it' : ''}`}
|
className={`clickToContext ${router?.query?.nid === nid ? 'outline-it' : ''}`}
|
||||||
onClick={(e) => {
|
onClick={async (e) => {
|
||||||
if (ignoreClick(e)) return
|
if (ignoreClick(e)) return
|
||||||
nid && router.replace({
|
nid && await router.replace({
|
||||||
pathname: router.pathname,
|
pathname: router.pathname,
|
||||||
query: {
|
query: {
|
||||||
...router.query,
|
...router.query,
|
||||||
@ -348,8 +348,7 @@ export default function Notifications ({ ssrData }) {
|
|||||||
nodata: true, // make sure nodata is set so we don't fetch on back/forward
|
nodata: true, // make sure nodata is set so we don't fetch on back/forward
|
||||||
checkedAt: lastChecked
|
checkedAt: lastChecked
|
||||||
}
|
}
|
||||||
},
|
}, router.asPath, { ...router.options, shallow: true })
|
||||||
router.asPath, { ...router.options, shallow: true })
|
|
||||||
client?.writeQuery({
|
client?.writeQuery({
|
||||||
query: HAS_NOTIFICATIONS,
|
query: HAS_NOTIFICATIONS,
|
||||||
data: {
|
data: {
|
||||||
@ -361,8 +360,9 @@ export default function Notifications ({ ssrData }) {
|
|||||||
|
|
||||||
const [fresh, old] = useMemo(() => {
|
const [fresh, old] = useMemo(() => {
|
||||||
if (!notifications) return [[], []]
|
if (!notifications) return [[], []]
|
||||||
|
const freshTime = checkedAt || lastChecked
|
||||||
return notifications.reduce((result, n) => {
|
return notifications.reduce((result, n) => {
|
||||||
result[new Date(n.sortTime).getTime() > new Date(checkedAt)?.getTime() ? 0 : 1].push(n)
|
result[new Date(n.sortTime).getTime() > new Date(freshTime)?.getTime() ? 0 : 1].push(n)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
[[], []])
|
[[], []])
|
||||||
|
@ -29,7 +29,6 @@ function getClient (uri) {
|
|||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
link: new HttpLink({ uri }),
|
link: new HttpLink({ uri }),
|
||||||
ssrMode: SSR,
|
ssrMode: SSR,
|
||||||
ssrForceFetchDelay: 100,
|
|
||||||
cache: new InMemoryCache({
|
cache: new InMemoryCache({
|
||||||
freezeResults: true,
|
freezeResults: true,
|
||||||
typePolicies: {
|
typePolicies: {
|
||||||
|
@ -25,7 +25,6 @@ function writeQuery (client, apollo, data) {
|
|||||||
query: gql`${apollo.query}`,
|
query: gql`${apollo.query}`,
|
||||||
data,
|
data,
|
||||||
variables: apollo.variables,
|
variables: apollo.variables,
|
||||||
broadcast: !SSR,
|
|
||||||
overwrite: SSR
|
overwrite: SSR
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user