More cache key debugging

This commit is contained in:
Jackson Harper
2024-08-15 13:20:29 +08:00
parent 5f94a2a38b
commit 913ad0c5d4
3 changed files with 36 additions and 18 deletions

View File

@ -54,7 +54,11 @@ import { theme } from '../../tokens/stitches.config'
import { emptyTrashMutation } from '../../../lib/networking/mutations/emptyTrashMutation'
import { State } from '../../../lib/networking/fragments/articleFragment'
import { useHandleAddUrl } from '../../../lib/hooks/useHandleAddUrl'
import { QueryClient, useQueryClient } from '@tanstack/react-query'
import {
InfiniteData,
QueryClient,
useQueryClient,
} from '@tanstack/react-query'
import { useGetViewer } from '../../../lib/networking/viewer/useGetViewer'
export type LayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT'
@ -86,7 +90,7 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
const [searchResults, setSearchResults] = useState<SearchItem[]>([])
const defaultQuery = {
limit: 5,
limit: 10,
folder: props.folder,
sortDescending: true,
searchQuery: undefined,
@ -210,6 +214,20 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {
activateCard(firstItem.node.id)
}, [libraryItems])
// const queryClient = useQueryClient()
// useEffect(() => {
// return () => {
// console.log('clearing old items')
// queryClient.setQueryData(
// ['libraryItems'],
// (data: InfiniteData<LibraryItems, unknown>) => ({
// pages: data.pages.slice(0, 1),
// pageParams: data.pageParams.slice(0, 1),
// })
// )
// }
// }, [])
const activateCard = useCallback(
(id: string) => {
if (!document.getElementById(id)) {