simplify persistence of page and scroll

This commit is contained in:
Boris Rorsvort 2026-01-12 14:49:33 +01:00
parent 1d4e2821ee
commit ff26593b17
4 changed files with 7 additions and 16 deletions

View File

@ -18,7 +18,6 @@ import {
import FavoriteIcon from '@material-ui/icons/Favorite'
import { withWidth } from '@material-ui/core'
import {
InfinitePagination,
InfiniteScrollWrapper,
List,
QuickFilter,
@ -241,7 +240,7 @@ const AlbumList = (props) => {
perPage={perPage}
pagination={
infiniteScrollEnabled ? (
<InfinitePagination />
false
) : (
<Pagination rowsPerPageOptions={perPageOptions} />
)

View File

@ -1 +0,0 @@
export const InfinitePagination = () => null

View File

@ -42,5 +42,4 @@ export * from './playlistUtils.js'
export * from './PathField.jsx'
export * from './ParticipantsInfo'
export * from './useInfiniteScroll.jsx'
export * from './InfinitePagination'
export * from './InfiniteScrollWrapper'

View File

@ -12,32 +12,26 @@ import { useHistory, useLocation } from 'react-router-dom'
const InfiniteScrollContext = createContext(null)
const scrollStateCache = new Map()
const getStorageKey = (pathname, filterValues) => {
const filterKey = JSON.stringify(filterValues || {})
return `infiniteScroll:${pathname}:${filterKey}`
return `${pathname}:${filterKey}`
}
const saveScrollState = (pathname, filterValues, pagesLoaded, scrollY) => {
const key = getStorageKey(pathname, filterValues)
sessionStorage.setItem(key, JSON.stringify({ pagesLoaded, scrollY }))
scrollStateCache.set(key, { pagesLoaded, scrollY })
}
const getScrollState = (pathname, filterValues) => {
const key = getStorageKey(pathname, filterValues)
const saved = sessionStorage.getItem(key)
if (saved) {
try {
return JSON.parse(saved)
} catch {
return null
}
}
return null
return scrollStateCache.get(key) || null
}
const clearScrollState = (pathname, filterValues) => {
const key = getStorageKey(pathname, filterValues)
sessionStorage.removeItem(key)
scrollStateCache.delete(key)
}
export const InfiniteScrollProvider = ({ children }) => {