rm related prop

This commit is contained in:
Martti Malmi 2024-01-08 11:24:14 +02:00
parent e905b4134d
commit 11e616c612
26 changed files with 30 additions and 88 deletions

View File

@ -19,7 +19,7 @@ module.exports = {
"react-refresh/only-export-components": "warn",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": "error",
},
root: true,
ignorePatterns: ["build/", "*.test.ts", "*.js"],

View File

@ -95,6 +95,7 @@
"@vitejs/plugin-react": "^4.2.0",
"@webbtc/webln-types": "^2.1.0",
"@webscopeio/react-textarea-autocomplete": "^4.9.2",
"@welldone-software/why-did-you-render": "^8.0.1",
"autoprefixer": "^10.4.16",
"config": "^3.3.9",
"eslint": "^8.48.0",

View File

@ -296,7 +296,6 @@ export function NoteCreator() {
return (
<Note
data={note.preview as TaggedNostrEvent}
related={[]}
options={{
showContextMenu: false,
showFooter: false,
@ -603,7 +602,6 @@ export function NoteCreator() {
</h4>
<Note
data={note.replyTo}
related={[]}
options={{
showFooter: false,
showContextMenu: false,
@ -623,7 +621,6 @@ export function NoteCreator() {
</h4>
<Note
data={note.quote}
related={[]}
options={{
showFooter: false,
showContextMenu: false,

View File

@ -1,7 +1,7 @@
import "./LongFormText.css";
import { NostrLink, TaggedNostrEvent } from "@snort/system";
import {useEventReactions, useReactions} from "@snort/system-react";
import { useEventReactions, useReactions } from "@snort/system-react";
import classNames from "classnames";
import React, { CSSProperties, useCallback, useRef, useState } from "react";
import { FormattedMessage, FormattedNumber } from "react-intl";

View File

@ -1,5 +1,5 @@
import { normalizeReaction } from "@snort/shared";
import { countLeadingZeros, NostrLink, ParsedZap, TaggedNostrEvent } from "@snort/system";
import { countLeadingZeros, NostrLink, TaggedNostrEvent } from "@snort/system";
import { useEventReactions, useReactions, useUserProfile } from "@snort/system-react";
import { Menu, MenuItem } from "@szhsin/react-menu";
import classNames from "classnames";

View File

@ -31,7 +31,7 @@ import Reveal from "./Reveal";
const TEXT_TRUNCATE_LENGTH = 400;
export function NoteInner(props: NoteProps) {
const { data: ev, related, highlight, options: opt, ignoreModeration = false, className, waitUntilInView } = props;
const { data: ev, highlight, options: opt, ignoreModeration = false, className, waitUntilInView } = props;
const baseClassName = classNames("note min-h-[110px] flex flex-col gap-4 card", className);
const navigate = useNavigate();

View File

@ -15,7 +15,6 @@ export default function NoteQuote({ link, depth }: { link: NostrLink; depth?: nu
return (
<Note
data={ev.data}
related={[]}
className="note-quote"
depth={(depth ?? 0) + 1}
options={{

View File

@ -87,7 +87,7 @@ export default function NoteReaction(props: NoteReactionProps) {
}}
/>
</div>
{root ? <Note data={root} options={opt} related={[]} depth={props.depth} /> : null}
{root ? <Note data={root} options={opt} depth={props.depth} /> : null}
{!root && refEvent ? (
<p>
<Link to={eventLink(refEvent[1] ?? "", refEvent[2])}>

View File

@ -1,6 +1,6 @@
import "./Reactions.css";
import { NostrLink, ParsedZap, socialGraphInstance, TaggedNostrEvent } from "@snort/system";
import { NostrLink, socialGraphInstance, TaggedNostrEvent } from "@snort/system";
import { useEventReactions, useReactions } from "@snort/system-react";
import { useEffect, useMemo, useState } from "react";
import { FormattedMessage, useIntl } from "react-intl";

View File

@ -1,6 +1,6 @@
import "./Thread.css";
import { EventExt, NostrLink, NostrPrefix, parseNostrLink, TaggedNostrEvent, u256 } from "@snort/system";
import { EventExt, NostrPrefix, parseNostrLink, TaggedNostrEvent, u256 } from "@snort/system";
import classNames from "classnames";
import { Fragment, ReactNode, useContext, useMemo, useState } from "react";
import { useIntl } from "react-intl";
@ -11,7 +11,6 @@ import Collapsed from "@/Components/Collapsed";
import Note from "@/Components/Event/Note";
import NoteGhost from "@/Components/Event/NoteGhost";
import { chainKey, ThreadContext, ThreadContextWrapper } from "@/Hooks/useThreadContext";
import { getAllLinkReactions } from "@/Utils";
import messages from "../messages";
@ -32,12 +31,11 @@ interface SubthreadProps {
isLastSubthread?: boolean;
active: u256;
notes: readonly TaggedNostrEvent[];
related: readonly TaggedNostrEvent[];
chains: Map<u256, Array<TaggedNostrEvent>>;
onNavigate: (e: TaggedNostrEvent) => void;
}
const Subthread = ({ active, notes, related, chains, onNavigate }: SubthreadProps) => {
const Subthread = ({ active, notes, chains, onNavigate }: SubthreadProps) => {
const renderSubthread = (a: TaggedNostrEvent, idx: number) => {
const isLastSubthread = idx === notes.length - 1;
const replies = getReplies(a.id, chains);
@ -60,7 +58,6 @@ const Subthread = ({ active, notes, related, chains, onNavigate }: SubthreadProp
active={active}
isLastSubthread={isLastSubthread}
notes={replies}
related={related}
chains={chains}
onNavigate={onNavigate}
/>
@ -77,7 +74,7 @@ interface ThreadNoteProps extends Omit<SubthreadProps, "notes"> {
isLast: boolean;
}
const ThreadNote = ({ active, note, isLast, isLastSubthread, related, chains, onNavigate }: ThreadNoteProps) => {
const ThreadNote = ({ active, note, isLast, isLastSubthread, chains, onNavigate }: ThreadNoteProps) => {
const { formatMessage } = useIntl();
const replies = getReplies(note.id, chains);
const activeInReplies = replies.map(r => r.id).includes(active);
@ -108,7 +105,6 @@ const ThreadNote = ({ active, note, isLast, isLastSubthread, related, chains, on
active={active}
isLastSubthread={isLastSubthread}
notes={replies}
related={related}
chains={chains}
onNavigate={onNavigate}
/>
@ -118,7 +114,7 @@ const ThreadNote = ({ active, note, isLast, isLastSubthread, related, chains, on
);
};
const TierTwo = ({ active, isLastSubthread, notes, related, chains, onNavigate }: SubthreadProps) => {
const TierTwo = ({ active, isLastSubthread, notes, chains, onNavigate }: SubthreadProps) => {
const [first, ...rest] = notes;
return (
@ -128,7 +124,6 @@ const TierTwo = ({ active, isLastSubthread, notes, related, chains, onNavigate }
onNavigate={onNavigate}
note={first}
chains={chains}
related={related}
isLastSubthread={isLastSubthread}
isLast={rest.length === 0}
/>
@ -142,7 +137,6 @@ const TierTwo = ({ active, isLastSubthread, notes, related, chains, onNavigate }
onNavigate={onNavigate}
note={r}
chains={chains}
related={related}
isLastSubthread={isLastSubthread}
isLast={lastReply}
/>
@ -152,7 +146,7 @@ const TierTwo = ({ active, isLastSubthread, notes, related, chains, onNavigate }
);
};
const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate }: SubthreadProps) => {
const TierThree = ({ active, isLastSubthread, notes, chains, onNavigate }: SubthreadProps) => {
const [first, ...rest] = notes;
const replies = getReplies(first.id, chains);
const hasMultipleNotes = rest.length > 0 || replies.length > 0;
@ -171,7 +165,6 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
className={classNames("thread-note", { "is-last-note": isLastSubthread && isLast })}
data={first}
key={first.id}
related={related}
threadChains={chains}
/>
<div className="line-container"></div>
@ -182,7 +175,6 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate
active={active}
isLastSubthread={isLastSubthread}
notes={replies}
related={related}
chains={chains}
onNavigate={onNavigate}
/>
@ -275,18 +267,7 @@ export function Thread(props: { onBack?: () => void; disableSpotlight?: boolean
}
const replies = thread.chains.get(from);
if (replies && thread.current) {
return (
<Subthread
active={thread.current}
notes={replies}
related={getAllLinkReactions(
thread.reactions,
replies.map(a => NostrLink.fromEvent(a)),
)}
chains={thread.chains}
onNavigate={navigateThread}
/>
);
return <Subthread active={thread.current} notes={replies} chains={thread.chains} onNavigate={navigateThread} />;
}
}

View File

@ -1,5 +1,3 @@
import { NostrLink } from "@snort/system";
import { useReactions } from "@snort/system-react";
import { useContext } from "react";
import { useArticles } from "@/Feed/ArticlesFeed";
@ -11,12 +9,6 @@ import Note from "../Event/Note";
export default function Articles() {
const data = useArticles();
const deck = useContext(DeckContext);
const related = useReactions(
"articles:reactions",
data.data?.map(v => NostrLink.fromEvent(v)) ?? [],
undefined,
true,
);
return (
<>
@ -24,7 +16,6 @@ export default function Articles() {
<Note
data={a}
key={a.id}
related={related.data ?? []}
options={{
longFormPreview: true,
}}

View File

@ -1,5 +1,5 @@
import { NostrLink, NoteCollection, ReqFilter, RequestBuilder } from "@snort/system";
import { useReactions, useRequestBuilder } from "@snort/system-react";
import { useRequestBuilder } from "@snort/system-react";
import { useMemo } from "react";
import { TimelineRenderer } from "@/Components/Feed/TimelineRenderer";
@ -18,12 +18,10 @@ export function GenericFeed({ link }: { link: NostrLink }) {
}, [link]);
const evs = useRequestBuilder(NoteCollection, sub);
const reactions = useReactions("generic:reactions", evs.data?.map(a => NostrLink.fromEvent(a)) ?? []);
return (
<TimelineRenderer
frags={[{ events: evs.data ?? [], refTime: 0 }]}
related={reactions.data ?? []}
latest={[]}
showLatest={() => {
//nothing

View File

@ -97,7 +97,6 @@ const Timeline = (props: TimelineProps) => {
refTime: mainFeed.at(0)?.created_at ?? unixNow(),
},
]}
related={feed.related ?? []}
latest={latestAuthors}
showLatest={t => onShowLatest(t)}
displayAs={displayAs}

View File

@ -1,8 +1,8 @@
import "./Timeline.css";
import { unixNow } from "@snort/shared";
import { EventKind, NostrEvent, NostrLink, TaggedNostrEvent } from "@snort/system";
import { SnortContext, useReactions } from "@snort/system-react";
import { EventKind, NostrEvent, TaggedNostrEvent } from "@snort/system";
import { SnortContext } from "@snort/system-react";
import { ReactNode, useCallback, useContext, useMemo, useState, useSyncExternalStore } from "react";
import { Link } from "react-router-dom";
@ -38,12 +38,6 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
cb => FollowsFeed.hook(cb, "*"),
() => FollowsFeed.snapshot(),
);
const reactions = useReactions(
"follows-feed-reactions",
feed.map(a => NostrLink.fromEvent(a)),
undefined,
true,
);
const system = useContext(SnortContext);
const { muted, isEventMuted } = useModeration();
@ -118,7 +112,6 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
/>
<TimelineRenderer
frags={[{ events: orderDescending(mainFeed.concat(mixinFiltered)), refTime: latest }]}
related={reactions.data ?? []}
latest={latestAuthors}
showLatest={t => onShowLatest(t)}
noteOnClick={props.noteOnClick}

View File

@ -1,8 +1,7 @@
import { TaggedNostrEvent } from "@snort/system";
import { ReactNode, useCallback } from "react";
import { ReactNode } from "react";
import Note from "@/Components/Event/Note";
import { findTag } from "@/Utils";
export interface TimelineFragment {
events: Array<TaggedNostrEvent>;
@ -12,7 +11,6 @@ export interface TimelineFragment {
export interface TimelineFragProps {
frag: TimelineFragment;
related: Array<TaggedNostrEvent>;
index: number;
noteRenderer?: (ev: TaggedNostrEvent) => ReactNode;
noteOnClick?: (ev: TaggedNostrEvent) => void;

View File

@ -14,7 +14,6 @@ import ProfileImage from "@/Components/User/ProfileImage";
export interface TimelineRendererProps {
frags: Array<TimelineFragment>;
related: Array<TaggedNostrEvent>;
/**
* List of pubkeys who have posted recently
*/
@ -96,7 +95,6 @@ export function TimelineRenderer(props: TimelineRendererProps) {
<ErrorBoundary key={frag.events[0]?.id + index}>
<TimelineFragment
frag={frag}
related={props.related}
noteRenderer={props.noteRenderer}
noteOnClick={props.noteOnClick}
noteContext={props.noteContext}

View File

@ -1,6 +1,5 @@
import { removeUndefined } from "@snort/shared";
import { NostrEvent, NostrLink, TaggedNostrEvent } from "@snort/system";
import { useReactions } from "@snort/system-react";
import classNames from "classnames";
import { useState } from "react";
@ -46,7 +45,6 @@ export default function TrendingNotes({ count = Infinity, small = false }: { cou
const displayAsInitial = small ? "list" : login.feedDisplayAs ?? "list";
const [displayAs, setDisplayAs] = useState<DisplayAs>(displayAsInitial);
const { isEventMuted } = useModeration();
const related = useReactions("trending", trendingNotesData?.map(a => NostrLink.fromEvent(a)) ?? [], undefined, true);
const [modalThread, setModalThread] = useState<NostrLink | undefined>(undefined);
if (error && !trendingNotesData) return <ErrorOrOffline error={error} className="p" />;
@ -78,7 +76,6 @@ export default function TrendingNotes({ count = Infinity, small = false }: { cou
<Note
key={e.id}
data={e as TaggedNostrEvent}
related={related?.data ?? []}
depth={0}
options={{
showFooter: !small,

View File

@ -11,10 +11,9 @@ import messages from "../messages";
interface BookmarksProps {
pubkey: HexKey;
bookmarks: readonly TaggedNostrEvent[];
related: readonly TaggedNostrEvent[];
}
const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
const Bookmarks = ({ pubkey, bookmarks }: BookmarksProps) => {
const [onlyPubkey, setOnlyPubkey] = useState<HexKey | "all">("all");
const { publicKey } = useLogin(s => ({ publicKey: s.publicKey }));
const ps = useMemo(() => {
@ -46,7 +45,6 @@ const Bookmarks = ({ pubkey, bookmarks, related }: BookmarksProps) => {
<Note
key={n.id}
data={n}
related={related}
options={{ showTime: false, showBookmarked: true, canUnbookmark: publicKey === pubkey }}
/>
);

View File

@ -130,7 +130,7 @@ export function SnortDeckLayout() {
className="long-form"
onClick={() => setDeckState({})}>
<div onClick={e => e.stopPropagation()}>
<LongFormText ev={deckState.article} isPreview={false} related={[]} />
<LongFormText ev={deckState.article} isPreview={false} />
</div>
</Modal>
</>

View File

@ -1,6 +1,6 @@
import { useUserProfile } from "@snort/system-react";
import classNames from "classnames";
import { useEffect, useState } from "react";
import { useEffect, useMemo, useState } from "react";
import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import { Link, useNavigate } from "react-router-dom";
@ -89,6 +89,12 @@ const WalletBalance = () => {
}
}, [wallet]);
const msgValues = useMemo(() => {
return {
amount: <FormattedNumber style="currency" currency="USD" value={(rates?.ask ?? 0) * (balance ?? 0) * 1e-8} />,
};
}, [balance, rates]);
return (
<div className="w-max flex flex-col max-xl:hidden">
<div className="grow flex items-center justify-between">
@ -101,15 +107,7 @@ const WalletBalance = () => {
</Link>
</div>
<div className="text-secondary text-sm">
<FormattedMessage
defaultMessage="~{amount}"
id="3QwfJR"
values={{
amount: (
<FormattedNumber style="currency" currency="USD" value={(rates?.ask ?? 0) * (balance ?? 0) * 1e-8} />
),
}}
/>
<FormattedMessage defaultMessage="~{amount}" id="3QwfJR" values={msgValues} />
</div>
</div>
);

View File

@ -5,7 +5,6 @@ import {
encodeTLVEntries,
EventKind,
MetadataCache,
NostrLink,
NostrPrefix,
TLVEntryType,
tryParseNostrLink,
@ -54,7 +53,7 @@ import ProfileTab, {
RelaysTab,
ZapsProfileTab,
} from "@/Pages/Profile/ProfileTab";
import { findTag, getLinkReactions, hexToBech32, parseId, unwrap } from "@/Utils";
import { findTag, hexToBech32, parseId, unwrap } from "@/Utils";
import { EmailRegex } from "@/Utils/Const";
import { ZapTarget } from "@/Utils/Zapper";

View File

@ -1,5 +1,4 @@
import { HexKey, NostrLink, NostrPrefix } from "@snort/system";
import { useReactions } from "@snort/system-react";
import { FormattedMessage } from "react-intl";
import { default as ZapElement } from "@/Components/Event/Zap";
@ -61,8 +60,7 @@ export function RelaysTab({ id }: { id: HexKey }) {
export function BookMarksTab({ id }: { id: HexKey }) {
const bookmarks = useBookmarkList(id);
const reactions = useReactions(`bookmark:reactions:{id}`, bookmarks.map(NostrLink.fromEvent));
return <Bookmarks pubkey={id} bookmarks={bookmarks} related={reactions.data ?? []} />;
return <Bookmarks pubkey={id} bookmarks={bookmarks} />;
}
const ProfileTab = {

View File

@ -5,7 +5,6 @@ import { useNavigate } from "react-router-dom";
import LndLogo from "@/assets/img/lnd-logo.png";
import AlbyIcon from "@/Components/Icons/Alby";
import BlueWallet from "@/Components/Icons/BlueWallet";
import CashuIcon from "@/Components/Icons/Cashu";
import Icon from "@/Components/Icons/Icon";
import NostrIcon from "@/Components/Icons/Nostrich";

View File

@ -25,7 +25,6 @@
"@types/node": "^20.5.9",
"@types/uuid": "^9.0.2",
"@types/ws": "^8.5.5",
"@welldone-software/why-did-you-render": "^8.0.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"ts-jest": "^29.1.0",

View File

@ -320,7 +320,6 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
fNew.forEach(f => {
const alreadyHave = inMemoryDB.findArray(f).map(e => {
console.log("got from inMemoryDB", e);
this.HandleEvent(e);
return e.id;
});

View File

@ -2954,6 +2954,7 @@ __metadata:
"@void-cat/api": ^1.0.12
"@webbtc/webln-types": ^2.1.0
"@webscopeio/react-textarea-autocomplete": ^4.9.2
"@welldone-software/why-did-you-render": ^8.0.1
autoprefixer: ^10.4.16
classnames: ^2.3.2
comlink: ^4.4.1
@ -3080,7 +3081,6 @@ __metadata:
"@types/node": ^20.5.9
"@types/uuid": ^9.0.2
"@types/ws": ^8.5.5
"@welldone-software/why-did-you-render": ^8.0.1
debug: ^4.3.4
eventemitter3: ^5.0.1
isomorphic-ws: ^5.0.0