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 {
isLoaded: isThreadPreferencesLoaded,
sort,
setSort,
setSort: baseSetSort,
view,
setView,
setView: baseSetView,
prioritizeFollowedUsers,
} = useThreadPreferences()
const postThreadQueryKey = createPostThreadQueryKey({
@@ -254,6 +254,24 @@ export function usePostThread({anchor}: {anchor?: string}) {
[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(
() => ({
state: {