Reset hidden items when params change
This commit is contained in:
@@ -30,9 +30,9 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
const {
|
const {
|
||||||
isLoaded: isThreadPreferencesLoaded,
|
isLoaded: isThreadPreferencesLoaded,
|
||||||
sort,
|
sort,
|
||||||
setSort,
|
setSort: baseSetSort,
|
||||||
view,
|
view,
|
||||||
setView,
|
setView: baseSetView,
|
||||||
prioritizeFollowedUsers,
|
prioritizeFollowedUsers,
|
||||||
} = useThreadPreferences()
|
} = useThreadPreferences()
|
||||||
const postThreadQueryKey = createPostThreadQueryKey({
|
const postThreadQueryKey = createPostThreadQueryKey({
|
||||||
@@ -254,6 +254,24 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
[qc, sort, view, postThreadQueryKey],
|
[qc, sort, view, postThreadQueryKey],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const setSort: typeof baseSetSort = useCallback(
|
||||||
|
nextSort => {
|
||||||
|
setHiddenRepliesVisible(false)
|
||||||
|
setAdditionalHiddenItems([])
|
||||||
|
baseSetSort(nextSort)
|
||||||
|
},
|
||||||
|
[baseSetSort, setAdditionalHiddenItems, setHiddenRepliesVisible],
|
||||||
|
)
|
||||||
|
|
||||||
|
const setView: typeof baseSetView = useCallback(
|
||||||
|
nextView => {
|
||||||
|
setHiddenRepliesVisible(false)
|
||||||
|
setAdditionalHiddenItems([])
|
||||||
|
baseSetView(nextView)
|
||||||
|
},
|
||||||
|
[baseSetView, setAdditionalHiddenItems, setHiddenRepliesVisible],
|
||||||
|
)
|
||||||
|
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
state: {
|
state: {
|
||||||
|
|||||||
Reference in New Issue
Block a user