mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-18 11:32:30 +02:00
fix bug with community "a" tags as root
This commit is contained in:
@@ -14,7 +14,7 @@ import SettingsView from "./views/settings";
|
||||
import NostrLinkView from "./views/link";
|
||||
import ProfileView from "./views/profile";
|
||||
import HashTagView from "./views/hashtag";
|
||||
import ThreadView from "./views/note";
|
||||
import ThreadView from "./views/thread";
|
||||
import NotificationsView from "./views/notifications";
|
||||
import DirectMessagesView from "./views/dms";
|
||||
import DirectMessageChatView from "./views/dms/chat";
|
||||
|
@@ -36,7 +36,7 @@ import { useRegisterIntersectionEntity } from "../../providers/intersection-obse
|
||||
import BookmarkButton from "./components/bookmark-button";
|
||||
import useCurrentAccount from "../../hooks/use-current-account";
|
||||
import NoteReactions from "./components/note-reactions";
|
||||
import ReplyForm from "../../views/note/components/reply-form";
|
||||
import ReplyForm from "../../views/thread/components/reply-form";
|
||||
import { getReferences } from "../../helpers/nostr/events";
|
||||
import Timestamp from "../timestamp";
|
||||
import OpenInDrawerButton from "../open-in-drawer-button";
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { Kind, nip19, validateEvent } from "nostr-tools";
|
||||
|
||||
import { ATag, DraftNostrEvent, isDTag, isETag, isPTag, NostrEvent, RTag, Tag } from "../../types/nostr-event";
|
||||
import { ATag, DraftNostrEvent, isDTag, isETag, NostrEvent, RTag, Tag } from "../../types/nostr-event";
|
||||
import { RelayConfig, RelayMode } from "../../classes/relay";
|
||||
import { getMatchNostrLink } from "../regexp";
|
||||
import { AddressPointer } from "nostr-tools/lib/types/nip19";
|
||||
import { safeJson } from "../parse";
|
||||
import { COMMUNITY_DEFINITION_KIND } from "./communities";
|
||||
|
||||
export function truncatedId(str: string, keep = 6) {
|
||||
if (str.length < keep * 2 + 3) return str;
|
||||
@@ -26,6 +27,7 @@ export function getEventUID(event: NostrEvent) {
|
||||
|
||||
export function isReply(event: NostrEvent | DraftNostrEvent) {
|
||||
if (event.kind === Kind.Repost) return false;
|
||||
// TODO: update this to only look for a "root" or "reply" tag
|
||||
return !!getReferences(event).replyId;
|
||||
}
|
||||
export function isMentionedInContent(event: NostrEvent | DraftNostrEvent, pubkey: string) {
|
||||
@@ -96,12 +98,19 @@ export function filterTagsByContentRefs(content: string, tags: Tag[], referenced
|
||||
return newTags;
|
||||
}
|
||||
|
||||
function isCommunityRefTag(t: Tag): t is ATag {
|
||||
return t.length >= 2 && t[0] === "a" && t[1].startsWith(COMMUNITY_DEFINITION_KIND + ":");
|
||||
}
|
||||
|
||||
export type EventReferences = ReturnType<typeof getReferences>;
|
||||
export function getReferences(event: NostrEvent | DraftNostrEvent) {
|
||||
const contentTagRefs = getContentTagRefs(event.content, event.tags);
|
||||
|
||||
const replyTag = event.tags.find((t) => t[3] === "reply");
|
||||
const rootTag = event.tags.find((t) => t[3] === "root");
|
||||
// find the root and reply tags.
|
||||
// NOTE: Ignore community reference tags since there is another client out there that is marking them as "root"
|
||||
// and it dose not make sense to "reply" to a community
|
||||
const replyTag = event.tags.find((t) => !isCommunityRefTag(t) && t[3] === "reply");
|
||||
const rootTag = event.tags.find((t) => !isCommunityRefTag(t) && t[3] === "root");
|
||||
const mentionTags = event.tags.find((t) => t[3] === "mention");
|
||||
|
||||
let replyId = replyTag?.[1];
|
||||
|
@@ -26,7 +26,7 @@ import {
|
||||
import { Location, RouteObject, RouterProvider, To, createMemoryRouter, useNavigate } from "react-router-dom";
|
||||
|
||||
import { ErrorBoundary } from "../components/error-boundary";
|
||||
import ThreadView from "../views/note";
|
||||
import ThreadView from "../views/thread";
|
||||
import { ChevronLeftIcon, ChevronRightIcon, ExternalLinkIcon } from "../components/icons";
|
||||
import { PageProviders } from ".";
|
||||
import { logger } from "../helpers/debug";
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { RouteObject } from "react-router-dom";
|
||||
|
||||
import ThreadView from "./views/note";
|
||||
import ThreadView from "./views/thread";
|
||||
|
||||
export const threadRoute: RouteObject = {
|
||||
path: "/n/:id",
|
||||
|
@@ -30,7 +30,7 @@ import { TrustProvider } from "../../../providers/trust";
|
||||
import { NoteContents } from "../../../components/note/text-note-contents";
|
||||
import NoteReactions from "../../../components/note/components/note-reactions";
|
||||
import { ReplyIcon } from "../../../components/icons";
|
||||
import ReplyForm from "../../note/components/reply-form";
|
||||
import ReplyForm from "../../thread/components/reply-form";
|
||||
import EventInteractionDetailsModal from "../../../components/event-interactions-modal";
|
||||
import NoteZapButton from "../../../components/note/note-zap-button";
|
||||
import useThreadColorLevelProps from "../../../hooks/use-thread-color-level-props";
|
||||
|
@@ -43,7 +43,7 @@ import NoteZapButton from "../../components/note/note-zap-button";
|
||||
import TorrentMenu from "./components/torrent-menu";
|
||||
import { QuoteRepostButton } from "../../components/note/components/quote-repost-button";
|
||||
import TorrentComments from "./components/torrents-comments";
|
||||
import ReplyForm from "../note/components/reply-form";
|
||||
import ReplyForm from "../thread/components/reply-form";
|
||||
import { getReferences } from "../../helpers/nostr/events";
|
||||
import MessageTextCircle01 from "../../components/icons/message-text-circle-01";
|
||||
|
||||
|
Reference in New Issue
Block a user