diff --git a/src/components/Column.tsx b/src/components/Column.tsx index f743d56..b3b79ab 100644 --- a/src/components/Column.tsx +++ b/src/components/Column.tsx @@ -1,4 +1,6 @@ import { Show, type JSX, type Component } from 'solid-js'; +import ArrowLeft from 'heroicons/24/outline/arrow-left.svg'; + import { useHandleCommand } from '@/hooks/useCommandBus'; import { ColumnContext, useColumnState } from '@/components/ColumnContext'; import ColumnContentDisplay from '@/components/ColumnContentDisplay'; @@ -57,8 +59,14 @@ const Column: Component = (props) => { {(columnContent) => (
-
); } + if (item.data.type === 'npub' && props.embedding) { + return ; + } + if (item.data.type === 'nprofile' && props.embedding) { + return ; + } return {item.content}; } if (item.type === 'HashTag') { @@ -61,6 +67,7 @@ const TextNoteContentDisplay = (props: TextNoteContentDisplayProps) => { } return ; } + console.error('Not all ParsedTextNoteNodes are covered', item); return null; }} diff --git a/src/components/textNote/TextNoteDisplay.tsx b/src/components/textNote/TextNoteDisplay.tsx index 741aeba..2e16970 100644 --- a/src/components/textNote/TextNoteDisplay.tsx +++ b/src/components/textNote/TextNoteDisplay.tsx @@ -165,16 +165,7 @@ const TextNoteDisplay: Component = (props) => { }); return ( -
{ - // FIXME - // columnContext?.setColumnContent({ - // type: 'Replies', - // eventId: event().rootEvent()?.id ?? props.event.id, - // }); - }} - > +
-
{createdAt()}
+
+ +
{ const matches = [ ...event.content.matchAll(/(?:#\[(?\d+)\])/g), ...event.content.matchAll(/#(?[^[-^`:-@!-/{-~\d\s][^[-^`:-@!-/{-~\s]+)/g), + // raw NIP-19 codes, NIP-21 links (NIP-27) // nrelay and naddr is not supported by nostr-tools - ...event.content.matchAll(/(?(npub|note|nprofile|nevent)1[ac-hj-np-z02-9]+)/gi), + ...event.content.matchAll( + /(?:nostr:)?(?(npub|note|nprofile|nevent)1[ac-hj-np-z02-9]+)/gi, + ), ...event.content.matchAll( /(?(?:https?|wss?):\/\/[-a-zA-Z0-9.]+(?:\/[-[\]~!$&'()*+.,:;@%\w]+|\/)*(?:\?[-[\]~!$&'()*+.,/:;%@\w&=]+)?(?:#[-[\]~!$&'()*+.,/:;%@\w?&=#]+)?)/g, ), @@ -117,10 +120,10 @@ const parseTextNote = (event: NostrEvent): ParsedTextNote => { }; result.push(mentionedEvent); } - } else if (match.groups?.nip19) { + } else if (match.groups?.mention) { pushPlainText(index); try { - const decoded = decode(match[0]); + const decoded = decode(match[1]); const bech32Entity: Bech32Entity = { type: 'Bech32Entity', content: match[0], @@ -129,6 +132,8 @@ const parseTextNote = (event: NostrEvent): ParsedTextNote => { result.push(bech32Entity); } catch (e) { console.error(`failed to parse Bech32 entity (NIP-19) but ignore this: ${match[0]}`); + pushPlainText(index + match[0].length); + return; } } else if (match.groups?.hashtag) { pushPlainText(index); diff --git a/src/nostr/useBatchedEvents.ts b/src/nostr/useBatchedEvents.ts index 12fa0fe..19960cb 100644 --- a/src/nostr/useBatchedEvents.ts +++ b/src/nostr/useBatchedEvents.ts @@ -286,6 +286,7 @@ export const useProfile = (propsProvider: () => UseProfileProps | null): UseProf // cacheTime is long so that the user see profiles instantly. staleTime: 5 * 60 * 1000, // 5 min cacheTime: 24 * 60 * 60 * 1000, // 1 day + refetchInterval: 5 * 60 * 1000, // 5 min }, ); @@ -331,7 +332,7 @@ export const useTextNote = (propsProvider: () => UseTextNoteProps | null): UseTe }, ); - const event = () => query.data; + const event = () => query.data ?? null; return { event, query }; }; @@ -362,6 +363,7 @@ export const useReactions = (propsProvider: () => UseReactionsProps | null): Use { staleTime: 1 * 60 * 1000, // 1 min cacheTime: 4 * 60 * 60 * 1000, // 4 hour + refetchInterval: 1 * 60 * 1000, // 1 min }, ); @@ -412,6 +414,7 @@ export const useDeprecatedReposts = ( { staleTime: 1 * 60 * 1000, // 1 min cacheTime: 4 * 60 * 60 * 1000, // 4 hour + refetchInterval: 1 * 60 * 1000, // 1 min }, ); @@ -458,7 +461,6 @@ export const useFollowings = (propsProvider: () => UseFollowingsProps | null): U staleTime: 5 * 60 * 1000, // 5 min cacheTime: 24 * 60 * 60 * 1000, // 24 hour refetchOnWindowFocus: false, - refetchInterval: 5 * 60 * 1000, // 5 min }, );