diff --git a/.changeset/violet-moles-peel.md b/.changeset/violet-moles-peel.md new file mode 100644 index 000000000..8c48cdbea --- /dev/null +++ b/.changeset/violet-moles-peel.md @@ -0,0 +1,5 @@ +--- +"nostrudel": minor +--- + +Show list links on muted by view diff --git a/src/views/lists/components/list-card.tsx b/src/views/lists/components/list-card.tsx index 20041ca12..d4ad68492 100644 --- a/src/views/lists/components/list-card.tsx +++ b/src/views/lists/components/list-card.tsx @@ -82,13 +82,17 @@ export function ListCardContent({ list, ...props }: Omit ); } +export function createListLink(list: NostrEvent) { + const isSpecialList = isSpecialListKind(list.kind); + return "/lists/" + (isSpecialList ? createCoordinate(list.kind, list.pubkey) : getSharableEventAddress(list)); +} + function ListCardRender({ list, hideCreator = false, ...props }: Omit & { list: NostrEvent; hideCreator?: boolean }) { const isSpecialList = isSpecialListKind(list.kind); - const link = isSpecialList ? createCoordinate(list.kind, list.pubkey) : getSharableEventAddress(list); // if there is a parent intersection observer, register this card const ref = useRef(null); @@ -101,7 +105,7 @@ function ListCardRender({ - + {getListName(list)} diff --git a/src/views/user/muted-by.tsx b/src/views/user/muted-by.tsx index 0dcd87c92..1756056c2 100644 --- a/src/views/user/muted-by.tsx +++ b/src/views/user/muted-by.tsx @@ -1,26 +1,41 @@ import { memo, useMemo, useRef } from "react"; -import { Flex, Heading, SimpleGrid } from "@chakra-ui/react"; -import { useOutletContext } from "react-router-dom"; +import { Flex, Heading, Link, SimpleGrid } from "@chakra-ui/react"; +import { Link as RouterLink, useOutletContext } from "react-router-dom"; import UserAvatarLink from "../../components/user-avatar-link"; import { UserLink } from "../../components/user-link"; import useTimelineLoader from "../../hooks/use-timeline-loader"; import { useReadRelayUrls } from "../../hooks/use-client-relays"; -import { MUTE_LIST_KIND, PEOPLE_LIST_KIND } from "../../helpers/nostr/lists"; +import { MUTE_LIST_KIND, PEOPLE_LIST_KIND, getListName, getPubkeysFromList } from "../../helpers/nostr/lists"; import useSubject from "../../hooks/use-subject"; import IntersectionObserverProvider, { useRegisterIntersectionEntity } from "../../providers/intersection-observer"; import { useTimelineCurserIntersectionCallback } from "../../hooks/use-timeline-cursor-intersection-callback"; import { getEventUID } from "../../helpers/nostr/events"; import VerticalPageLayout from "../../components/vertical-page-layout"; +import { NostrEvent } from "../../types/nostr-event"; +import SuperMap from "../../classes/super-map"; +import { createListLink } from "../lists/components/list-card"; -const User = memo(({ pubkey, listId }: { pubkey: string; listId: string }) => { - const ref = useRef(null); - useRegisterIntersectionEntity(ref, listId); +function ListLink({ list }: { list: NostrEvent }) { + const ref = useRef(null); + useRegisterIntersectionEntity(ref, getEventUID(list)); return ( - + + {getListName(list)} ({getPubkeysFromList(list).length}) + + ); +} +const User = memo(({ pubkey, lists }: { pubkey: string; lists: NostrEvent[] }) => { + return ( + - + + + {lists.map((list) => ( + + ))} + ); }); @@ -37,11 +52,11 @@ export default function UserMutedByTab() { const lists = useSubject(timeline.timeline); const pubkeys = useMemo(() => { - const keys = new Map(); + const dir = new SuperMap(() => []); for (const list of lists) { - keys.set(list.pubkey, getEventUID(list)); + dir.get(list.pubkey).push(list); } - return Array.from(keys).map((a) => ({ pubkey: a[0], listId: a[1] })); + return Array.from(dir).map((a) => ({ pubkey: a[0], lists: a[1] })); }, [lists]); const callback = useTimelineCurserIntersectionCallback(timeline); @@ -49,9 +64,9 @@ export default function UserMutedByTab() { return ( - - {pubkeys.map(({ pubkey, listId }) => ( - + + {pubkeys.map(({ pubkey, lists }) => ( + ))} {pubkeys.length === 0 && (