From 2455176dae1f172e1cdb37ce8dc82e1f015d09c5 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Thu, 8 Feb 2024 20:03:23 +0000 Subject: [PATCH] add option to use your mailboxes when selecting relays --- src/providers/route/require-read-relays.tsx | 20 +++++++++++++++++--- src/views/relays/app/index.tsx | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/providers/route/require-read-relays.tsx b/src/providers/route/require-read-relays.tsx index 41d6aa8c6..08dacdb35 100644 --- a/src/providers/route/require-read-relays.tsx +++ b/src/providers/route/require-read-relays.tsx @@ -12,6 +12,8 @@ import { safeRelayUrls } from "../../helpers/relay"; import RelaySet from "../../classes/relay-set"; import HoverLinkOverlay from "../../components/hover-link-overlay"; import { useLocation } from "react-router-dom"; +import useCurrentAccount from "../../hooks/use-current-account"; +import useUserMailboxes from "../../hooks/use-user-mailboxes"; const JapaneseRelays = safeRelayUrls([ "wss://r.kojira.io", @@ -39,20 +41,26 @@ function RelaySetCard({ label, read, write }: { label: string; read: Iterable - {RelaySet.from(read, write).urls.join(", ")} + {RelaySet.from(read, write).urls.map((url) => ( + + {url} + + ))} ); } export default function RequireReadRelays({ children }: PropsWithChildren) { + const account = useCurrentAccount(); + const mailboxes = useUserMailboxes(account?.pubkey); const readRelays = useReadRelays(); const offline = useSubject(offlineMode); const location = useLocation(); if (readRelays.size === 0 && !offline && !location.pathname.startsWith("/relays")) return ( - + Setup App Relays @@ -61,7 +69,13 @@ export default function RequireReadRelays({ children }: PropsWithChildren) { App Relays are stored locally and are used to fetch your timeline and other users notes - + {!account && ( + + )} + {mailboxes && } + diff --git a/src/views/relays/app/index.tsx b/src/views/relays/app/index.tsx index e7f1ad8b9..78e8dbd5b 100644 --- a/src/views/relays/app/index.tsx +++ b/src/views/relays/app/index.tsx @@ -63,7 +63,7 @@ export default function AppRelays() { {writeRelays.size === 0 && ( - There are write relays set, any note you create might not be saved + There are no write relays set, any note you create might not be saved )}