From 215502a0f04c43afe5f6041734c6f31d597bdbc2 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sat, 25 Oct 2025 23:06:42 +0800 Subject: [PATCH] fix: reset scroll position record on account switch --- src/layouts/PrimaryPageLayout/index.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/layouts/PrimaryPageLayout/index.tsx b/src/layouts/PrimaryPageLayout/index.tsx index a1400a59..135249a2 100644 --- a/src/layouts/PrimaryPageLayout/index.tsx +++ b/src/layouts/PrimaryPageLayout/index.tsx @@ -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(null) const smallScreenScrollAreaRef = useRef(null) const smallScreenLastScrollTopRef = useRef(0) @@ -67,6 +69,10 @@ const PrimaryPageLayout = forwardRef( } }, [current, enableSingleColumnLayout, display]) + useEffect(() => { + smallScreenLastScrollTopRef.current = 0 + }, [pubkey]) + if (enableSingleColumnLayout) { return (