Merge pull request #4286 from omnivore-app/fix/web-crash-fix
Fix empty edges in useMemo
This commit is contained in:
@ -164,6 +164,9 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
|
||||
const items =
|
||||
itemsPages?.pages
|
||||
.flatMap((ad: LibraryItems) => {
|
||||
if (!ad.edges) {
|
||||
return []
|
||||
}
|
||||
return ad.edges.map((it) => ({
|
||||
...it,
|
||||
isLoading: it.node.state === 'PROCESSING',
|
||||
|
||||
@ -277,6 +277,9 @@ export function useGetLibraryItems(
|
||||
query: fullQuery,
|
||||
includeContent: false,
|
||||
})) as LibraryItemsData
|
||||
if (response.search.errorCodes?.length) {
|
||||
throw new Error(response.search.errorCodes[0])
|
||||
}
|
||||
let wasUnchanged = false
|
||||
if (cached && cached.pageParams.indexOf(pageParam) > -1) {
|
||||
const idx = cached.pageParams.indexOf(pageParam)
|
||||
@ -326,8 +329,6 @@ export function useGetLibraryItems(
|
||||
return true
|
||||
})
|
||||
)
|
||||
console.log('setting filteredPages: ', filteredPages)
|
||||
|
||||
return {
|
||||
...data,
|
||||
pages: filteredPages,
|
||||
|
||||
@ -2,8 +2,16 @@
|
||||
import NextErrorComponent from 'next/error'
|
||||
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { useEffect } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
const MyError = ({ statusCode, hasGetInitialPropsRun, err }: any) => {
|
||||
const queryClient = useQueryClient()
|
||||
useEffect(() => {
|
||||
console.log('unhandled exception occurred, clearing cached data.')
|
||||
queryClient.clear()
|
||||
}, [])
|
||||
|
||||
if (!hasGetInitialPropsRun && err) {
|
||||
// getInitialProps is not called in case of
|
||||
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
|
||||
|
||||
Reference in New Issue
Block a user