mirror of
https://github.com/dergigi/boris.git
synced 2025-12-18 07:04:19 +01:00
refactor: standardize @ prefix handling and improve npub/nprofile display
- Fix getNpubFallbackDisplay to return names without @ prefix - Update all call sites to consistently add @ when rendering mentions - Fix incomplete error handling in getNpubFallbackDisplay catch block - Add nprofile support to addLoadingClassToProfileLinks - Extract shared isProfileInCacheOrStore utility to eliminate duplicate loading state checks - Update ResolvedMention and NostrMentionLink to use shared utility This ensures consistent @ prefix handling across all profile display contexts and eliminates code duplication for profile loading state detection.
This commit is contained in:
@@ -5,7 +5,7 @@ import { Hooks } from 'applesauce-react'
|
||||
import { Models, Helpers } from 'applesauce-core'
|
||||
import { decode, npubEncode } from 'nostr-tools/nip19'
|
||||
import { getProfileDisplayName } from '../utils/nostrUriResolver'
|
||||
import { loadCachedProfiles } from '../services/profileService'
|
||||
import { isProfileInCacheOrStore } from '../utils/profileLoadingUtils'
|
||||
|
||||
const { getPubkeyFromDecodeResult } = Helpers
|
||||
|
||||
@@ -28,14 +28,7 @@ const ResolvedMention: React.FC<ResolvedMentionProps> = ({ encoded }) => {
|
||||
// Check if profile is in cache or eventStore
|
||||
const isInCacheOrStore = useMemo(() => {
|
||||
if (!pubkey) return false
|
||||
// Check cache
|
||||
const cached = loadCachedProfiles([pubkey])
|
||||
if (cached.has(pubkey)) {
|
||||
return true
|
||||
}
|
||||
// Check eventStore
|
||||
const eventStoreProfile = eventStore?.getEvent(pubkey + ':0')
|
||||
return !!eventStoreProfile
|
||||
return isProfileInCacheOrStore(pubkey, eventStore)
|
||||
}, [pubkey, eventStore])
|
||||
|
||||
// Show loading if profile doesn't exist and not in cache/store
|
||||
|
||||
Reference in New Issue
Block a user