diff --git a/src/js/components/events/EventComponent.tsx b/src/js/components/events/EventComponent.tsx index 4337b81e7..0f5de2c4c 100644 --- a/src/js/components/events/EventComponent.tsx +++ b/src/js/components/events/EventComponent.tsx @@ -22,7 +22,7 @@ declare global { } interface EventComponentProps { - id?: string; + id: string; standalone?: boolean; asInlineQuote?: boolean; showReplies?: number; @@ -39,9 +39,8 @@ const EventComponent = (props: EventComponentProps) => { const [state, setState] = useState<{ [key: string]: any }>({ sortedReplies: [], meta: {}, - event: Events.db.by('id', props.id), + event: Events.db.by('id', Key.toNostrHexAddress(props.id)), }); - const subscriptions: (() => void)[] = []; const retrievingTimeout = useRef(); const unmounted = useRef(false); @@ -93,9 +92,6 @@ const EventComponent = (props: EventComponentProps) => { hexId && Events.getEventById(hexId, true, (event) => handleEvent(event)); return () => { - subscriptions.forEach((unsub) => { - unsub(); - }); unmounted.current = true; }; }, []); diff --git a/src/js/components/events/NoteImage.tsx b/src/js/components/events/NoteImage.tsx index f77affc0e..9b471e6fc 100644 --- a/src/js/components/events/NoteImage.tsx +++ b/src/js/components/events/NoteImage.tsx @@ -97,6 +97,9 @@ function NoteImage(props: { event: Event; fadeIn?: boolean }) { if (props.event.kind !== 1) { const id = Events.getEventReplyingTo(props.event); + if (!id) { + return null; + } return ; } const attachments = [] as { type: string; url: string }[]; diff --git a/src/js/components/events/Zap.tsx b/src/js/components/events/Zap.tsx index 80270d580..149c15b63 100644 --- a/src/js/components/events/Zap.tsx +++ b/src/js/components/events/Zap.tsx @@ -45,6 +45,10 @@ export default function Zap(props: Props) { : () => null; }, [zappedId]); + if (!zappedId) { + return null; + } + let zappingUser = null as string | null; try { zappingUser = Events.getZappingUser(props.event.id); diff --git a/src/js/components/user/ProfileCard.tsx b/src/js/components/user/ProfileCard.tsx index 11bb8d817..cadbd61a5 100644 --- a/src/js/components/user/ProfileCard.tsx +++ b/src/js/components/user/ProfileCard.tsx @@ -7,6 +7,7 @@ import Events from '../../nostr/Events'; import Key from '../../nostr/Key'; import PubSub from '../../nostr/PubSub'; import SocialNetwork from '../../nostr/SocialNetwork'; +import { ID } from '../../nostr/UserIds'; import { translate as t } from '../../translations/Translation.mjs'; import Follow from '../buttons/Follow'; import Show from '../helpers/Show'; @@ -19,7 +20,7 @@ import Stats from './Stats'; const ProfileCard = (props: { hexPub: string; npub: string }) => { const { hexPub, npub } = props; - const [profile, setProfile] = useState({}); + const [profile, setProfile] = useState(SocialNetwork.profiles.get(ID(hexPub))); const [lightning, setLightning] = useState(''); const [website, setWebsite] = useState(''); const [loggedIn, setLoggedIn] = useState(false);