fix: 🐛

This commit is contained in:
codytseng
2025-05-07 23:14:24 +08:00
parent 04c84db0ae
commit 55862da1d3
3 changed files with 12 additions and 9 deletions

View File

@@ -27,6 +27,7 @@ export type TPrimaryPageName = keyof typeof PRIMARY_PAGE_MAP
type TPrimaryPageContext = {
navigate: (page: TPrimaryPageName) => void
current: TPrimaryPageName | null
display: boolean
}
type TSecondaryPageContext = {
@@ -200,7 +201,6 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
setPrimaryPages((prev) => [...prev, { name: page, element: PRIMARY_PAGE_MAP[page] }])
}
setCurrentPrimaryPage(page)
PRIMARY_PAGE_REF_MAP[page].current?.scrollToTop()
if (isSmallScreen) {
clearSecondaryPages()
}
@@ -249,7 +249,8 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
<PrimaryPageContext.Provider
value={{
navigate: navigatePrimaryPage,
current: secondaryStack.length === 0 ? currentPrimaryPage : null
current: currentPrimaryPage,
display: secondaryStack.length === 0
}}
>
<SecondaryPageContext.Provider
@@ -295,7 +296,8 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
<PrimaryPageContext.Provider
value={{
navigate: navigatePrimaryPage,
current: currentPrimaryPage
current: currentPrimaryPage,
display: false
}}
>
<SecondaryPageContext.Provider
@@ -326,7 +328,8 @@ export function PageManager({ maxStackSize = 5 }: { maxStackSize?: number }) {
<PrimaryPageContext.Provider
value={{
navigate: navigatePrimaryPage,
current: currentPrimaryPage
current: currentPrimaryPage,
display: true
}}
>
<SecondaryPageContext.Provider

View File

@@ -1,11 +1,11 @@
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Skeleton } from '@/components/ui/skeleton'
import { generateImageByPubkey } from '@/lib/pubkey'
import { cn } from '@/lib/utils'
import { usePrimaryPage } from '@/PageManager'
import { useNostr } from '@/providers/NostrProvider'
import { UserRound } from 'lucide-react'
import { useMemo } from 'react'
import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar'
import { Skeleton } from '../ui/skeleton'
import BottomNavigationBarItem from './BottomNavigationBarItem'
export default function AccountButton() {

View File

@@ -26,7 +26,7 @@ const PrimaryPageLayout = forwardRef(
const smallScreenScrollAreaRef = useRef<HTMLDivElement>(null)
const smallScreenLastScrollTopRef = useRef(0)
const { isSmallScreen } = useScreenSize()
const { current } = usePrimaryPage()
const { current, display } = usePrimaryPage()
useImperativeHandle(
ref,
@@ -44,7 +44,7 @@ const PrimaryPageLayout = forwardRef(
useEffect(() => {
if (isSmallScreen) {
if (smallScreenScrollAreaRef.current?.checkVisibility()) {
window.scrollTo({ top: smallScreenLastScrollTopRef.current })
window.scrollTo({ top: smallScreenLastScrollTopRef.current, behavior: 'instant' })
}
const handleScroll = () => {
if (smallScreenScrollAreaRef.current?.checkVisibility()) {
@@ -56,7 +56,7 @@ const PrimaryPageLayout = forwardRef(
window.removeEventListener('scroll', handleScroll)
}
}
}, [current, isSmallScreen])
}, [current, isSmallScreen, display])
if (isSmallScreen) {
return (