- {item.component}
+ {primaryNoteView ? (
+ // Show primary note view with back button on mobile
+
+
+
+
+
+
+
+ {primaryNoteView}
- ))}
- {primaryPages.map(({ name, element, props }) => (
-
- {props ? cloneElement(element as React.ReactElement, props) : element}
- ))}
+ ) : (
+ <>
+ {!!secondaryStack.length &&
+ secondaryStack.map((item, index) => (
+
+ {item.component}
+
+ ))}
+ {primaryPages.map(({ name, element, props }) => (
+
+ {props ? cloneElement(element as React.ReactElement, props) : element}
+
+ ))}
+ >
+ )}
diff --git a/src/components/UserAvatar/index.tsx b/src/components/UserAvatar/index.tsx
index 07c4d8f..6176ba8 100644
--- a/src/components/UserAvatar/index.tsx
+++ b/src/components/UserAvatar/index.tsx
@@ -1,13 +1,11 @@
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
-import { Drawer, DrawerContent, DrawerOverlay } from '@/components/ui/drawer'
-import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card'
import { Skeleton } from '@/components/ui/skeleton'
import { useFetchProfile } from '@/hooks'
import { generateImageByPubkey } from '@/lib/pubkey'
+import { toProfile } from '@/lib/link'
import { cn } from '@/lib/utils'
-import { useScreenSize } from '@/providers/ScreenSizeProvider'
-import { useMemo, useState } from 'react'
-import ProfileCard from '../ProfileCard'
+import { useSmartProfileNavigation } from '@/PageManager'
+import { useMemo } from 'react'
const UserAvatarSizeCnMap = {
large: 'w-24 h-24',
@@ -30,8 +28,7 @@ export default function UserAvatar({
size?: 'large' | 'big' | 'semiBig' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny'
}) {
const { profile } = useFetchProfile(userId)
- const { isSmallScreen } = useScreenSize()
- const [drawerOpen, setDrawerOpen] = useState(false)
+ const { navigateToProfile } = useSmartProfileNavigation()
const defaultAvatar = useMemo(
() => (profile?.pubkey ? generateImageByPubkey(profile.pubkey) : ''),
[profile]
@@ -42,59 +39,30 @@ export default function UserAvatar({
)
}
- const { avatar, pubkey } = profile
- if (isSmallScreen) {
- return (
- <>
-
setDrawerOpen(true)}
- >
-
-
-
-
-
-
- setDrawerOpen(false)} />
-
-
-
-
- >
- )
- }
+ const { avatar, pubkey } = profile
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
+
navigateToProfile(toProfile(pubkey))}
+ >
+
+
+
+
+
)
}
export function SimpleUserAvatar({
userId,
size = 'normal',
- className,
- onClick
+ className
}: {
userId: string
- size?: 'large' | 'big' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny'
+ size?: 'large' | 'big' | 'semiBig' | 'normal' | 'medium' | 'small' | 'xSmall' | 'tiny'
className?: string
- onClick?: (e: React.MouseEvent
) => void
}) {
const { profile } = useFetchProfile(userId)
const defaultAvatar = useMemo(
@@ -107,14 +75,15 @@ export function SimpleUserAvatar({
)
}
+
const { avatar, pubkey } = profile
return (
-
+
)
-}
+}
\ No newline at end of file
diff --git a/src/components/Username/index.tsx b/src/components/Username/index.tsx
index 4b1ffa6..c693342 100644
--- a/src/components/Username/index.tsx
+++ b/src/components/Username/index.tsx
@@ -1,11 +1,8 @@
-import { Drawer, DrawerContent, DrawerOverlay } from '@/components/ui/drawer'
-import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card'
import { Skeleton } from '@/components/ui/skeleton'
import { useFetchProfile } from '@/hooks'
+import { toProfile } from '@/lib/link'
import { cn } from '@/lib/utils'
-import { useScreenSize } from '@/providers/ScreenSizeProvider'
-import { useState } from 'react'
-import ProfileCard from '../ProfileCard'
+import { useSmartProfileNavigation } from '@/PageManager'
export default function Username({
userId,
@@ -21,8 +18,7 @@ export default function Username({
withoutSkeleton?: boolean
}) {
const { profile } = useFetchProfile(userId)
- const { isSmallScreen } = useScreenSize()
- const [drawerOpen, setDrawerOpen] = useState(false)
+ const { navigateToProfile } = useSmartProfileNavigation()
if (!profile && !withoutSkeleton) {
return (
@@ -31,44 +27,21 @@ export default function Username({
)
}
- if (!profile) return null
- const { username, pubkey } = profile
-
- if (isSmallScreen) {
- return (
- <>
-
setDrawerOpen(true)}
- >
- {showAt && '@'}
- {username}
-
-
- setDrawerOpen(false)} />
-
-
-
-
- >
- )
+ if (!profile) {
+ return null
}
+ const { username, pubkey } = profile
+
return (
-
-
-
- {showAt && '@'}
- {username}
-
-
-
-
-
-
+
navigateToProfile(toProfile(pubkey))}
+ >
+ {showAt && '@'}
+ {username}
+
)
}
@@ -86,6 +59,7 @@ export function SimpleUsername({
withoutSkeleton?: boolean
}) {
const { profile } = useFetchProfile(userId)
+
if (!profile && !withoutSkeleton) {
return (
@@ -93,14 +67,17 @@ export function SimpleUsername({
)
}
- if (!profile) return null
+
+ if (!profile) {
+ return null
+ }
const { username } = profile
return (
-
+
{showAt && '@'}
{username}
)
-}
+}
\ No newline at end of file