refactor: reactions grouping and other fixes
This commit is contained in:
@ -32,13 +32,8 @@ export function LongFormText(props: LongFormTextProps) {
|
||||
const [reading, setReading] = useState(false);
|
||||
const [showMore, setShowMore] = useState(false);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const related = useReactions(
|
||||
NostrLink.fromEvent(props.ev).id + "related",
|
||||
[NostrLink.fromEvent(props.ev)],
|
||||
undefined,
|
||||
false,
|
||||
);
|
||||
const { reactions, reposts, zaps } = useEventReactions(NostrLink.fromEvent(props.ev), related.data ?? []);
|
||||
const related = useReactions("note:reactions", [NostrLink.fromEvent(props.ev)], undefined, false);
|
||||
const { reactions, reposts, zaps } = useEventReactions(NostrLink.fromEvent(props.ev), related);
|
||||
|
||||
function previewText() {
|
||||
return (
|
||||
|
@ -10,8 +10,8 @@ import { findTag } from "@/Utils";
|
||||
export default function NostrFileHeader({ link }: { link: NostrLink }) {
|
||||
const ev = useEventFeed(link);
|
||||
|
||||
if (!ev.data) return <PageSpinner />;
|
||||
return <NostrFileElement ev={ev.data} />;
|
||||
if (!ev) return <PageSpinner />;
|
||||
return <NostrFileElement ev={ev} />;
|
||||
}
|
||||
|
||||
export function NostrFileElement({ ev }: { ev: NostrEvent }) {
|
||||
|
@ -36,8 +36,8 @@ export default function NoteFooter(props: NoteFooterProps) {
|
||||
const link = useMemo(() => NostrLink.fromEvent(ev), [ev.id]);
|
||||
const ids = useMemo(() => [link], [link]);
|
||||
|
||||
const related = useReactions(link.id + "related", ids, undefined, false);
|
||||
const { reactions, zaps, reposts } = useEventReactions(link, related.data ?? []);
|
||||
const related = useReactions("note:reactions", ids, undefined, false);
|
||||
const { reactions, zaps, reposts } = useEventReactions(link, related);
|
||||
const { positive } = reactions;
|
||||
|
||||
const { formatMessage } = useIntl();
|
||||
|
@ -11,11 +11,11 @@ const options = {
|
||||
|
||||
export default function NoteQuote({ link, depth }: { link: NostrLink; depth?: number }) {
|
||||
const ev = useEventFeed(link);
|
||||
if (!ev.data)
|
||||
if (!ev)
|
||||
return (
|
||||
<div className="note-quote flex items-center justify-center h-[110px]">
|
||||
<PageSpinner />
|
||||
</div>
|
||||
);
|
||||
return <Note data={ev.data} className="note-quote" depth={(depth ?? 0) + 1} options={options} />;
|
||||
return <Note data={ev} className="note-quote" depth={(depth ?? 0) + 1} options={options} />;
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ const ReactionsModal = ({ show, setShow, event }: ReactionsModalProps) => {
|
||||
|
||||
const link = NostrLink.fromEvent(event);
|
||||
|
||||
const related = useReactions(link.id + "related", [link], undefined, false);
|
||||
const { reactions, zaps, reposts } = useEventReactions(link, related.data ?? []);
|
||||
const related = useReactions("note:reactions", [link], undefined, false);
|
||||
const { reactions, zaps, reposts } = useEventReactions(link, related);
|
||||
const { positive, negative } = reactions;
|
||||
|
||||
const sortEvents = events =>
|
||||
const sortEvents = (events: Array<TaggedNostrEvent>) =>
|
||||
events.sort(
|
||||
(a, b) => socialGraphInstance.getFollowDistance(a.pubkey) - socialGraphInstance.getFollowDistance(b.pubkey),
|
||||
);
|
||||
|
@ -16,7 +16,7 @@ export default function Articles() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{orderDescending(data.data ?? []).map(a => (
|
||||
{orderDescending(data).map(a => (
|
||||
<Note
|
||||
data={a}
|
||||
key={a.id}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { NostrLink, NoteCollection, ReqFilter, RequestBuilder } from "@snort/system";
|
||||
import { NostrLink, ReqFilter, RequestBuilder } from "@snort/system";
|
||||
import { useRequestBuilder } from "@snort/system-react";
|
||||
import { useMemo } from "react";
|
||||
|
||||
@ -6,7 +6,6 @@ import { TimelineRenderer } from "@/Components/Feed/TimelineRenderer";
|
||||
|
||||
export function GenericFeed({ link }: { link: NostrLink }) {
|
||||
const sub = useMemo(() => {
|
||||
console.debug(link);
|
||||
const sub = new RequestBuilder("generic");
|
||||
sub.withOptions({ leaveOpen: true });
|
||||
const reqs = JSON.parse(link.id) as Array<ReqFilter>;
|
||||
@ -17,11 +16,11 @@ export function GenericFeed({ link }: { link: NostrLink }) {
|
||||
return sub;
|
||||
}, [link]);
|
||||
|
||||
const evs = useRequestBuilder(NoteCollection, sub);
|
||||
const evs = useRequestBuilder(sub);
|
||||
|
||||
return (
|
||||
<TimelineRenderer
|
||||
frags={[{ events: evs.data ?? [], refTime: 0 }]}
|
||||
frags={[{ events: evs, refTime: 0 }]}
|
||||
latest={[]}
|
||||
showLatest={() => {
|
||||
//nothing
|
||||
|
@ -70,7 +70,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
};
|
||||
const mixinFiltered = useMemo(() => {
|
||||
const mainFeedIds = new Set(mainFeed.map(a => a.id));
|
||||
return (mixin.data.data ?? [])
|
||||
return (mixin.data ?? [])
|
||||
.filter(a => !mainFeedIds.has(a.id) && postsOnly(a) && !isEventMuted(a))
|
||||
.filter(a => a.tags.filter(a => a[0] === "t").length < 5)
|
||||
.filter(a => !oldest || a.created_at >= oldest)
|
||||
|
@ -38,7 +38,7 @@ export default function SearchBox() {
|
||||
const subject: TimelineSubject = {
|
||||
type: "profile_keyword",
|
||||
discriminator: search,
|
||||
items: [search],
|
||||
items: search ? [search] : [],
|
||||
relay: undefined,
|
||||
streams: false,
|
||||
};
|
||||
|
@ -84,10 +84,8 @@ export default function SendSats(props: SendSatsProps) {
|
||||
useEffect(() => {
|
||||
if (props.targets && props.show) {
|
||||
try {
|
||||
console.debug("loading zapper");
|
||||
const zapper = new Zapper(system, publisher);
|
||||
zapper.load(props.targets).then(() => {
|
||||
console.debug(zapper);
|
||||
setZapper(zapper);
|
||||
});
|
||||
} catch (e) {
|
||||
|
@ -31,7 +31,7 @@ export default function TrendingNotes({ count = Infinity, small = false }: { cou
|
||||
return removeUndefined(
|
||||
data.notes.map(a => {
|
||||
const ev = a.event;
|
||||
if (!System.Optimizer.schnorrVerify(ev)) {
|
||||
if (!System.optimizer.schnorrVerify(ev)) {
|
||||
console.error(`Event with invalid sig\n\n${ev}\n\nfrom ${trendingNotesUrl}`);
|
||||
return;
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ export function ProfileLink({
|
||||
children?: ReactNode;
|
||||
} & Omit<LinkProps, "to">) {
|
||||
const system = useContext(SnortContext);
|
||||
const relays = system.relayCache.getFromCache(pubkey)
|
||||
const relays = system.relayCache
|
||||
.getFromCache(pubkey)
|
||||
?.relays?.filter(a => a.settings.write)
|
||||
?.map(a => a.url);
|
||||
|
||||
|
Reference in New Issue
Block a user