import { type Component, Show } from 'solid-js'; import { type Event as NostrEvent } from 'nostr-tools/pure'; import EmojiDisplay from '@/components/EmojiDisplay'; import EventDisplay from '@/components/event/EventDisplay'; import UserDisplayName from '@/components/UserDisplayName'; import useConfig from '@/core/useConfig'; import useFormatDate from '@/hooks/useFormatDate'; import useModalState from '@/hooks/useModalState'; import { useTranslation } from '@/i18n/useTranslation'; import { reaction } from '@/nostr/event'; import useEvent from '@/nostr/useEvent'; import useProfile from '@/nostr/useProfile'; import ensureNonNull from '@/utils/ensureNonNull'; import { thumbnailUrl } from '@/utils/url'; type ReactionDisplayProps = { event: NostrEvent; }; const ReactionDisplay: Component = (props) => { const i18n = useTranslation(); const formatDate = useFormatDate(); const { shouldMuteEvent } = useConfig(); const { showProfile } = useModalState(); const event = () => reaction(props.event); const eventId = () => event().lastTaggedEventId(); const { profile } = useProfile(() => ({ pubkey: props.event.pubkey, })); const { event: reactedEvent, query: reactedEventQuery } = useEvent(() => ensureNonNull([eventId()] as const)(([eventIdNonNull]) => ({ eventId: eventIdNonNull, })), ); const isRemoved = () => reactedEventQuery.isSuccess && reactedEvent() == null; return ( // if the reacted event is not found, it should be a removed event
{(url) => ( icon )}
{i18n.t('notification.reacted')}
{formatDate(event().createdAtAsDate())}
{i18n.t('general.loading')} {eventId()}
} keyed > {(ev) => }
); }; export default ReactionDisplay;