Fixed homepage filters setting, names, and userId category
This commit is contained in:
@ -8,9 +8,11 @@ function useStoryIndex(annLength: number | undefined) {
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
|
||||
const withReset = <T>(f: SetState<T>) => (...args: Parameters<SetState<T>>) => {
|
||||
console.log('resetting index')
|
||||
setIndex(0)
|
||||
setSearchParams(prev => ({ ...prev, storyIndex: '0' }), { replace: true })
|
||||
setSearchParams(prev => ({
|
||||
...Object.fromEntries(prev),
|
||||
storyIndex: '0'
|
||||
}), { replace: true })
|
||||
f(...args)
|
||||
}
|
||||
|
||||
@ -24,14 +26,20 @@ function useStoryIndex(annLength: number | undefined) {
|
||||
|
||||
const increment = () => setIndex(prev => {
|
||||
const newIndex = (prev + 1) % (annLength || 1)
|
||||
setSearchParams(prev => ({ ...prev, storyIndex: newIndex.toString() }), { replace: true })
|
||||
setSearchParams(prev => ({
|
||||
...Object.fromEntries(prev),
|
||||
storyIndex: newIndex.toString()
|
||||
}), { replace: true })
|
||||
|
||||
return newIndex
|
||||
})
|
||||
|
||||
const decrement = () => setIndex(prev => {
|
||||
const newIndex = prev > 0 ? (prev - 1) : 0
|
||||
setSearchParams(prev => ({ ...prev, storyIndex: newIndex.toString() }), { replace: true })
|
||||
setSearchParams(prev => ({
|
||||
...Object.fromEntries(prev),
|
||||
storyIndex: newIndex.toString()
|
||||
}), { replace: true })
|
||||
|
||||
return newIndex
|
||||
})
|
||||
|
Reference in New Issue
Block a user