constant onClick param in some Notes
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Martti Malmi 2024-01-08 16:33:03 +02:00
parent 8a75b5bce8
commit ca2cb76380
9 changed files with 38 additions and 28 deletions

View File

@ -2,7 +2,7 @@ import "./Thread.css";
import { EventExt, NostrPrefix, parseNostrLink, TaggedNostrEvent, u256 } from "@snort/system"; import { EventExt, NostrPrefix, parseNostrLink, TaggedNostrEvent, u256 } from "@snort/system";
import classNames from "classnames"; import classNames from "classnames";
import { Fragment, ReactNode, useContext, useMemo, useState } from "react"; import { Fragment, ReactNode, useCallback, useContext, useMemo, useState } from "react";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
@ -233,10 +233,13 @@ export function Thread(props: { onBack?: () => void; disableSpotlight?: boolean
[props.disableSpotlight], [props.disableSpotlight],
); );
function navigateThread(e: TaggedNostrEvent) { const navigateThread = useCallback(
thread.setCurrent(e.id); (e: TaggedNostrEvent) => {
//router.navigate(`/${NostrLink.fromEvent(e).encode()}`, { replace: true }) thread.setCurrent(e.id);
} // navigate(`/${NostrLink.fromEvent(e).encode()}`, { replace: true });
},
[thread],
);
const parent = useMemo(() => { const parent = useMemo(() => {
if (thread.root) { if (thread.root) {

View File

@ -1,5 +1,5 @@
import Fuse from "fuse.js";
import { CachedMetadata } from "@snort/system"; import { CachedMetadata } from "@snort/system";
import Fuse from "fuse.js";
export type FuzzySearchResult = { export type FuzzySearchResult = {
pubkey: string; pubkey: string;

View File

@ -1,7 +1,7 @@
import "./Deck.css"; import "./Deck.css";
import { NostrLink, TaggedNostrEvent } from "@snort/system"; import { NostrLink, TaggedNostrEvent } from "@snort/system";
import { createContext, useEffect, useState } from "react"; import { createContext, useCallback, useEffect, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Link, Outlet, useNavigate } from "react-router-dom"; import { Link, Outlet, useNavigate } from "react-router-dom";
@ -176,6 +176,13 @@ function ArticlesCol() {
} }
function MediaCol({ setThread }: { setThread: (e: NostrLink) => void }) { function MediaCol({ setThread }: { setThread: (e: NostrLink) => void }) {
const noteOnClick = useCallback(
e => {
setThread(NostrLink.fromEvent(e));
},
[setThread],
);
return ( return (
<div> <div>
<div className="flex items-center gap-2 p-2 border-b border-border-color"> <div className="flex items-center gap-2 p-2 border-b border-border-color">
@ -192,7 +199,7 @@ function MediaCol({ setThread }: { setThread: (e: NostrLink) => void }) {
}} }}
displayAs="grid" displayAs="grid"
showDisplayAsSelector={false} showDisplayAsSelector={false}
noteOnClick={e => setThread(NostrLink.fromEvent(e))} noteOnClick={noteOnClick}
/> />
</div> </div>
); );

View File

@ -102,17 +102,17 @@ export function Header() {
function NoteTitle({ link }: { link: NostrLink }) { function NoteTitle({ link }: { link: NostrLink }) {
const ev = useEventFeed(link); const ev = useEventFeed(link);
const values = useMemo(() => {
return { name: <DisplayName pubkey={ev.data?.pubkey ?? ""} /> };
}, [ev.data?.pubkey]);
if (!ev.data?.pubkey) { if (!ev.data?.pubkey) {
return <FormattedMessage defaultMessage="Note" id="qMePPG" />; return <FormattedMessage defaultMessage="Note" id="qMePPG" />;
} }
return ( return (
<> <>
<FormattedMessage <FormattedMessage defaultMessage="Note by {name}" id="ALdW69" values={values} />
defaultMessage="Note by {name}"
id="ALdW69"
values={{ name: <DisplayName pubkey={ev.data.pubkey} /> }}
/>
</> </>
); );
} }

View File

@ -2,9 +2,9 @@ import "./ProfilePage.css";
import { fetchNip05Pubkey, LNURL } from "@snort/shared"; import { fetchNip05Pubkey, LNURL } from "@snort/shared";
import { import {
CachedMetadata,
encodeTLVEntries, encodeTLVEntries,
EventKind, EventKind,
CachedMetadata,
NostrPrefix, NostrPrefix,
TLVEntryType, TLVEntryType,
tryParseNostrLink, tryParseNostrLink,

View File

@ -1,7 +1,7 @@
import { unixNow } from "@snort/shared"; import { unixNow } from "@snort/shared";
import { NostrLink } from "@snort/system"; import { NostrLink } from "@snort/system";
import { SnortContext } from "@snort/system-react"; import { SnortContext } from "@snort/system-react";
import { lazy, useContext, useEffect, useState } from "react"; import { lazy, useContext, useEffect, useMemo, useState } from "react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Link, Outlet, RouteObject, useParams } from "react-router-dom"; import { Link, Outlet, RouteObject, useParams } from "react-router-dom";
@ -164,20 +164,20 @@ export const NotesTab = () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const deckContext = useContext(DeckContext); const deckContext = useContext(DeckContext);
const noteOnClick = useMemo(() => {
if (deckContext) {
return ev => {
deckContext.setThread(NostrLink.fromEvent(ev));
};
}
return undefined;
}, [deckContext]);
return ( return (
<> <>
<FollowsHint /> <FollowsHint />
<TaskList /> <TaskList />
<TimelineFollows <TimelineFollows postsOnly={true} noteOnClick={noteOnClick} />
postsOnly={true}
noteOnClick={
deckContext
? ev => {
deckContext.setThread(NostrLink.fromEvent(ev));
}
: undefined
}
/>
</> </>
); );
}; };

View File

@ -1,6 +1,6 @@
import { base64 } from "@scure/base"; import { base64 } from "@scure/base";
import { removeUndefined, unwrap } from "@snort/shared"; import { removeUndefined, unwrap } from "@snort/shared";
import { EventKind, EventPublisher, CachedMetadata, TaggedNostrEvent } from "@snort/system"; import { CachedMetadata, EventKind, EventPublisher, TaggedNostrEvent } from "@snort/system";
import { UserCache } from "@/Cache"; import { UserCache } from "@/Cache";
import SnortApi from "@/External/SnortApi"; import SnortApi from "@/External/SnortApi";

View File

@ -6,10 +6,10 @@ import { bytesToHex } from "@noble/hashes/utils";
import { base32hex, bech32 } from "@scure/base"; import { base32hex, bech32 } from "@scure/base";
import { isHex, isOffline } from "@snort/shared"; import { isHex, isOffline } from "@snort/shared";
import { import {
CachedMetadata,
encodeTLV, encodeTLV,
EventKind, EventKind,
HexKey, HexKey,
CachedMetadata,
NostrEvent, NostrEvent,
NostrLink, NostrLink,
NostrPrefix, NostrPrefix,

View File

@ -2,7 +2,7 @@ import { removeUndefined, throwIfOffline } from "@snort/shared";
import { mapEventToProfile, NostrEvent, NostrSystem, ProfileLoaderService, socialGraphInstance } from "@snort/system"; import { mapEventToProfile, NostrEvent, NostrSystem, ProfileLoaderService, socialGraphInstance } from "@snort/system";
import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache"; import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache";
import { addEventToFuzzySearch, addProfileToFuzzySearch } from "@/Db/FuzzySearch"; import { addEventToFuzzySearch } from "@/Db/FuzzySearch";
import { LoginStore } from "@/Utils/Login"; import { LoginStore } from "@/Utils/Login";
import { hasWasm, WasmOptimizer } from "@/Utils/wasm"; import { hasWasm, WasmOptimizer } from "@/Utils/wasm";