mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Remove the cache busting
This commit is contained in:
parent
3ceb18400c
commit
49b66f3504
3 changed files with 19 additions and 34 deletions
|
|
@ -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<LibraryItems, unknown>) => {
|
||||
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 ? (
|
||||
<Button
|
||||
style="ctaGray"
|
||||
css={{
|
||||
cursor: props.isValidating ? 'not-allowed' : 'pointer',
|
||||
}}
|
||||
onClick={props.loadMore}
|
||||
disabled={props.isValidating}
|
||||
>
|
||||
{props.isValidating ? 'Loading' : 'Load More'}
|
||||
</Button>
|
||||
props.isValidating ? (
|
||||
<Spinner />
|
||||
) : (
|
||||
<Button
|
||||
style="ctaGray"
|
||||
css={{
|
||||
cursor: props.isValidating ? 'not-allowed' : 'pointer',
|
||||
}}
|
||||
onClick={props.loadMore}
|
||||
disabled={props.isValidating}
|
||||
>
|
||||
{props.isValidating ? 'Loading' : 'More search results'}
|
||||
</Button>
|
||||
)
|
||||
) : (
|
||||
<StyledText style="caption"></StyledText>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue