diff --git a/packages/web/components/templates/library/LibraryContainer.tsx b/packages/web/components/templates/library/LibraryContainer.tsx index 26cda5a09..97d43f8aa 100644 --- a/packages/web/components/templates/library/LibraryContainer.tsx +++ b/packages/web/components/templates/library/LibraryContainer.tsx @@ -56,6 +56,7 @@ import { State } from '../../../lib/networking/fragments/articleFragment' import { useHandleAddUrl } from '../../../lib/hooks/useHandleAddUrl' import { InfiniteData, useQueryClient } from '@tanstack/react-query' import { useGetViewer } from '../../../lib/networking/viewer/useGetViewer' +import { Spinner } from '@phosphor-icons/react/dist/ssr' export type LayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT' @@ -210,29 +211,6 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element { activateCard(firstItem.node.id) }, [libraryItems]) - const queryClient = useQueryClient() - useEffect(() => { - return () => { - const keys = queryClient - .getQueryCache() - .findAll({ queryKey: ['libraryItems', props.folder ?? 'home'] }) - - keys.forEach((query) => { - console.log('clearing old items') - queryClient.setQueryData( - query.queryKey, - (data: InfiniteData) => { - console.log('unloading data: ', data) - return { - pages: data.pages.slice(0, 3), - pageParams: data.pageParams.slice(0, 3), - } - } - ) - }) - } - }, [queryClient]) - const activateCard = useCallback( (id: string) => { if (!document.getElementById(id)) { @@ -318,6 +296,7 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element { }, [libraryItems, activeCardId]) useEffect(() => { + console.log('active card id: ', activeCardId) if (activeCardId && !alreadyScrolled.current) { scrollToActiveCard(activeCardId) alreadyScrolled.current = true @@ -1173,16 +1152,20 @@ export function LibraryItemsLayout( css={{ width: '100%', mt: '$2', mb: '$4' }} > {props.hasMore ? ( - + props.isValidating ? ( + + ) : ( + + ) ) : ( )} diff --git a/packages/web/lib/networking/library_items/useLibraryItems.tsx b/packages/web/lib/networking/library_items/useLibraryItems.tsx index eca1eb681..b22335535 100644 --- a/packages/web/lib/networking/library_items/useLibraryItems.tsx +++ b/packages/web/lib/networking/library_items/useLibraryItems.tsx @@ -86,6 +86,7 @@ export const updateItemProperty = ( .findAll({ queryKey: ['libraryItems'] }) keys.forEach((query) => { + console.log('updating query: ', query.queryKey) queryClient.setQueryData(query.queryKey, (data: any) => { if (!data) return data const updatedData = { @@ -107,6 +108,7 @@ export const updateItemProperty = ( return updatedData }) }) + console.log('updated: foundItemSlug', foundItemSlug) if (foundItemSlug || slug) { queryClient.setQueryData( ['libraryItem', foundItemSlug ?? slug], diff --git a/packages/web/pages/[username]/[slug]/index.tsx b/packages/web/pages/[username]/[slug]/index.tsx index 7fcd54189..087c7ed06 100644 --- a/packages/web/pages/[username]/[slug]/index.tsx +++ b/packages/web/pages/[username]/[slug]/index.tsx @@ -305,7 +305,7 @@ export default function Reader(): JSX.Element { perform: () => { const navReturn = window.localStorage.getItem('nav-return') if (navReturn) { - router.push(navReturn) + router.push(navReturn, navReturn, { scroll: false }) return } const query = window.sessionStorage.getItem('q')