Reset hidden items when params change

This commit is contained in:
Eric Bailey
2025-06-04 11:32:52 -05:00
parent a115b6780f
commit f38811854b
+20 -2
View File
@@ -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: {