fix: reset scroll position record on account switch

This commit is contained in:
codytseng
2025-10-25 23:06:42 +08:00
parent def13e4f34
commit 215502a0f0

View File

@@ -3,6 +3,7 @@ import { Titlebar } from '@/components/Titlebar'
import { ScrollArea } from '@/components/ui/scroll-area'
import { TPrimaryPageName, usePrimaryPage } from '@/PageManager'
import { DeepBrowsingProvider } from '@/providers/DeepBrowsingProvider'
import { useNostr } from '@/providers/NostrProvider'
import { useUserPreferences } from '@/providers/UserPreferencesProvider'
import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'
@@ -23,6 +24,7 @@ const PrimaryPageLayout = forwardRef(
},
ref
) => {
const { pubkey } = useNostr()
const scrollAreaRef = useRef<HTMLDivElement>(null)
const smallScreenScrollAreaRef = useRef<HTMLDivElement>(null)
const smallScreenLastScrollTopRef = useRef(0)
@@ -67,6 +69,10 @@ const PrimaryPageLayout = forwardRef(
}
}, [current, enableSingleColumnLayout, display])
useEffect(() => {
smallScreenLastScrollTopRef.current = 0
}, [pubkey])
if (enableSingleColumnLayout) {
return (
<DeepBrowsingProvider active={current === pageName && display}>