diff --git a/.changeset/good-dryers-thank.md b/.changeset/good-dryers-thank.md new file mode 100644 index 000000000..ada58adf5 --- /dev/null +++ b/.changeset/good-dryers-thank.md @@ -0,0 +1,5 @@ +--- +"nostrudel": minor +--- + +Add relay view diff --git a/src/app.tsx b/src/app.tsx index e21cde823..ae21fd0b1 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -36,6 +36,7 @@ import UserStreamsTab from "./views/user/streams"; import { PageProviders } from "./providers"; import RelaysView from "./views/relays"; import RelayReviewsView from "./views/relays/reviews"; +import RelayView from "./views/relays/relay"; const StreamsView = React.lazy(() => import("./views/streams")); const StreamView = React.lazy(() => import("./views/streams/stream")); @@ -107,6 +108,7 @@ const router = createHashRouter([ { path: "settings", element: }, { path: "relays/reviews", element: }, { path: "relays", element: }, + { path: "r/:relay", element: }, { path: "notifications", element: }, { path: "search", element: }, { path: "dm", element: }, diff --git a/src/components/relay-icon-stack.tsx b/src/components/relay-icon-stack.tsx index a0633df1d..4e31ecac9 100644 --- a/src/components/relay-icon-stack.tsx +++ b/src/components/relay-icon-stack.tsx @@ -1,18 +1,19 @@ import { - Avatar, - Box, Flex, FlexProps, - IconButton, + Link, Modal, ModalBody, ModalCloseButton, ModalContent, ModalHeader, ModalOverlay, + Tag, Text, useDisclosure, } from "@chakra-ui/react"; +import { Link as RouterLink } from "react-router-dom"; + import { RelayFavicon } from "./relay-favicon"; import relayScoreboardService from "../services/relay-scoreboard"; @@ -34,18 +35,27 @@ export function RelayIconStack({ relays, maxRelays, ...props }: { relays: string )} - + - Relays + + Seen on relays: + - - + + {topRelays.map((url) => ( - - - {url} - + + + {url} + ))} diff --git a/src/views/relays/components/relay-card.tsx b/src/views/relays/components/relay-card.tsx index 71b7ecc95..9cacb30ef 100644 --- a/src/views/relays/components/relay-card.tsx +++ b/src/views/relays/components/relay-card.tsx @@ -1,13 +1,12 @@ import { Box, Button, - ButtonGroup, + ButtonProps, Card, CardBody, CardFooter, CardHeader, CardProps, - Code, Flex, Heading, IconButton, @@ -19,8 +18,6 @@ import { ModalHeader, ModalOverlay, ModalProps, - Spacer, - Text, useDisclosure, } from "@chakra-ui/react"; import { Link as RouterLink } from "react-router-dom"; @@ -41,36 +38,6 @@ import styled from "@emotion/styled"; import { PropsWithChildren } from "react"; import RawJson from "../../../components/debug-modals/raw-json"; -function RelayReviewsModal({ relay, ...props }: { relay: string } & Omit) { - const readRelays = useReadRelayUrls(); - const timeline = useTimelineLoader(`${relay}-reviews`, readRelays, { - kinds: [1985], - "#r": [relay], - "#l": ["review/relay"], - }); - - const events = useSubject(timeline.timeline); - - return ( - - - - - {relay} reviews - - - - - {events.map((event) => ( - - ))} - - - - - ); -} - const B = styled.span` font-weight: bold; `; @@ -100,7 +67,7 @@ export function RelayMetadata({ url }: { url: string }) { ); } -export function RelayJoinAction({ url }: { url: string }) { +export function RelayJoinAction({ url, ...props }: { url: string } & Omit) { const account = useCurrentAccount(); const clientRelays = useClientRelays(); const joined = clientRelays.some((r) => r.url === url); @@ -111,7 +78,7 @@ export function RelayJoinAction({ url }: { url: string }) { variant="outline" onClick={() => clientRelaysService.removeRelay(url)} isDisabled={!account} - size="sm" + {...props} > Leave @@ -120,26 +87,19 @@ export function RelayJoinAction({ url }: { url: string }) { colorScheme="green" onClick={() => clientRelaysService.addRelay(url, RelayMode.ALL)} isDisabled={!account} - size="sm" + {...props} > Join ); } -export function DebugButton({ url, ...props }: { url: string } & Omit) { +export function RelayDebugButton({ url, ...props }: { url: string } & Omit) { const { info } = useRelayInfo(url); const debugModal = useDisclosure(); return ( <> - } - aria-label="Show JSON" - onClick={debugModal.onToggle} - variant="ghost" - size="sm" - {...props} - /> + } aria-label="Show JSON" onClick={debugModal.onToggle} variant="ghost" {...props} /> {debugModal.isOpen && ( @@ -157,30 +117,22 @@ export function DebugButton({ url, ...props }: { url: string } & Omit) { - const reviewsModal = useDisclosure(); - return ( <> - {url} + {url} - - - + - + - +