diff --git a/src/components/NotePostForm.tsx b/src/components/NotePostForm.tsx index f74c4e3..fa5ca04 100644 --- a/src/components/NotePostForm.tsx +++ b/src/components/NotePostForm.tsx @@ -60,6 +60,9 @@ const extract = (parsed: ParsedTextNote) => { } else if (node.data.type === 'note') { eventReferences.push(node.data.data); } + // TODO nevent can contain an event not only textnote (kind:1). + // In my understanding, it is not allowed to include other kinds of events in `tags`. + // It is needed to verify that the kind of the event is 1. } }); diff --git a/src/components/column/FollwingColumn.tsx b/src/components/column/FollwingColumn.tsx index 551e2d6..3434332 100644 --- a/src/components/column/FollwingColumn.tsx +++ b/src/components/column/FollwingColumn.tsx @@ -1,4 +1,4 @@ -import { Component } from 'solid-js'; +import { Component, createEffect, onCleanup, onMount } from 'solid-js'; import Home from 'heroicons/24/outline/home.svg'; import { uniq } from 'lodash'; @@ -25,7 +25,7 @@ const FollowingColumn: Component = (props) => { const { followingPubkeys } = useFollowings(() => ({ pubkey: props.column.pubkey })); - const { events: followingsPosts } = useSubscription(() => { + const { events } = useSubscription(() => { const authors = uniq([...followingPubkeys()]); if (authors.length === 0) return null; return { @@ -45,6 +45,13 @@ const FollowingColumn: Component = (props) => { }; }); + createEffect(() => { + console.log('home', events()); + }); + + onMount(() => console.log('home timeline mounted')); + onCleanup(() => console.log('home timeline unmounted')); + return ( = (props) => { columnIndex={props.columnIndex} lastColumn={props.lastColumn} > - + ); }; diff --git a/src/nostr/event.ts b/src/nostr/event.ts index 9d0f4d4..6dfa14a 100644 --- a/src/nostr/event.ts +++ b/src/nostr/event.ts @@ -1,5 +1,6 @@ import uniq from 'lodash/uniq'; import { Kind, Event as NostrEvent } from 'nostr-tools'; +import { z } from 'zod'; export type EventMarker = 'reply' | 'root' | 'mention'; @@ -22,13 +23,25 @@ export type ContentWarning = { reason?: string; }; -const IdRegex = /^[0-9a-fA-f]{64}$/; +const IdRegex = /^[0-9a-f]{64}$/; export const isValidId = (s: string): boolean => { const result = typeof s === 'string' && s.length === 64 && IdRegex.test(s); if (!result) console.warn('invalid id is ignored: ', s); return result; }; +/* +// TODO event validation and normalization +const eventSchema = z.object({ + id: z.string().length(64).regex(IdRegex), + pubkey: z.string().length(64).regex(IdRegex), + created_at: z.number().int(), + kind: z.number(), + tags: z.array(z.array(z.string())), + content: z.string(), +}); +*/ + const eventWrapper = (event: NostrEvent) => { let memoizedMarkedEventTags: MarkedEventTag[] | undefined;