diff --git a/src/components/layout/Linkify.tsx b/src/components/layout/Linkify.tsx index 86d49d7..8ee60c9 100644 --- a/src/components/layout/Linkify.tsx +++ b/src/components/layout/Linkify.tsx @@ -1,20 +1,22 @@ import { JSX } from 'solid-js'; interface LinkifyProps { - text: string; + initialText: string; } export default function Linkify(props: LinkifyProps): JSX.Element { + // By naming this "initialText" we can prove to eslint that the props won't change + const text = props.initialText; const links: (string | JSX.Element)[] = []; const pattern = /((https?:\/\/|www\.)\S+)/gi; let lastIndex = 0; let match; - while ((match = pattern.exec(props.text)) !== null) { + while ((match = pattern.exec(text)) !== null) { const link = match[1]; const href = link.startsWith('http') ? link : `https://${link}`; - const beforeLink = props.text.slice(lastIndex, match.index); + const beforeLink = text.slice(lastIndex, match.index); lastIndex = pattern.lastIndex; if (beforeLink) { @@ -24,7 +26,7 @@ export default function Linkify(props: LinkifyProps): JSX.Element { links.push({link}); } - const remainingText = props.text.slice(lastIndex); + const remainingText = text.slice(lastIndex); if (remainingText) { links.push(remainingText); } diff --git a/src/components/waitlist/Notes.tsx b/src/components/waitlist/Notes.tsx index ead8f95..0da404a 100644 --- a/src/components/waitlist/Notes.tsx +++ b/src/components/waitlist/Notes.tsx @@ -1,4 +1,4 @@ -import { Component, For } from "solid-js"; +import { Component, For, createEffect, createSignal } from "solid-js"; import { Event, nip19 } from "nostr-tools" import { Linkify } from "~/components/layout"; @@ -8,26 +8,27 @@ type NostrEvent = { } const Note: Component<{ e: NostrEvent }> = (props) => { - const e = props.e; - const date = new Date(e.created_at * 1000); - const linkRoot = "https://snort.social/e/"; - let noteId; + const [noteId, setNoteId] = createSignal(""); + + createEffect(() => { + if (props.e.id) { + setNoteId(nip19.noteEncode(props.e.id)) + } + }) - if (e.id) { - noteId = nip19.noteEncode(e.id) - } return (

- + {/* {props.e.content} */} +

- - {date.toLocaleString()} + + {(new Date(props.e.created_at * 1000)).toLocaleString()}