fix notifications glitchiness
This commit is contained in:
parent
42234eae9b
commit
23257d8c63
|
@ -42,9 +42,9 @@ function NotificationLayout ({ children, nid, href, as }) {
|
|||
return (
|
||||
<div
|
||||
className={`clickToContext ${router?.query?.nid === nid ? 'outline-it' : ''}`}
|
||||
onClick={(e) => {
|
||||
onClick={async (e) => {
|
||||
if (ignoreClick(e)) return
|
||||
nid && router.replace({
|
||||
nid && await router.replace({
|
||||
pathname: router.pathname,
|
||||
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
|
||||
checkedAt: lastChecked
|
||||
}
|
||||
},
|
||||
router.asPath, { ...router.options, shallow: true })
|
||||
}, router.asPath, { ...router.options, shallow: true })
|
||||
client?.writeQuery({
|
||||
query: HAS_NOTIFICATIONS,
|
||||
data: {
|
||||
|
@ -361,8 +360,9 @@ export default function Notifications ({ ssrData }) {
|
|||
|
||||
const [fresh, old] = useMemo(() => {
|
||||
if (!notifications) return [[], []]
|
||||
const freshTime = checkedAt || lastChecked
|
||||
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
|
||||
},
|
||||
[[], []])
|
||||
|
|
|
@ -29,7 +29,6 @@ function getClient (uri) {
|
|||
return new ApolloClient({
|
||||
link: new HttpLink({ uri }),
|
||||
ssrMode: SSR,
|
||||
ssrForceFetchDelay: 100,
|
||||
cache: new InMemoryCache({
|
||||
freezeResults: true,
|
||||
typePolicies: {
|
||||
|
|
|
@ -25,7 +25,6 @@ function writeQuery (client, apollo, data) {
|
|||
query: gql`${apollo.query}`,
|
||||
data,
|
||||
variables: apollo.variables,
|
||||
broadcast: !SSR,
|
||||
overwrite: SSR
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue