Skip to content

Commit

Permalink
change to button
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Feb 8, 2024
1 parent 2455176 commit e10dfe2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/providers/route/require-read-relays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ export default function RequireReadRelays({ children }: PropsWithChildren) {
const offline = useSubject(offlineMode);
const location = useLocation();

const setRelaysToMailboxes = useCallback<MouseEventHandler>(
(e) => {
if (!mailboxes) return;
clientRelaysService.readRelays.next(RelaySet.from(mailboxes.inbox));
clientRelaysService.writeRelays.next(RelaySet.from(mailboxes.outbox));
clientRelaysService.saveRelays();
},
[mailboxes],
);

if (readRelays.size === 0 && !offline && !location.pathname.startsWith("/relays"))
return (
<Flex direction="column" maxW="md" mx="auto" alignItems="center" gap="4" px="2" py="10">
Expand All @@ -74,7 +84,11 @@ export default function RequireReadRelays({ children }: PropsWithChildren) {
Login to use your relays
</Button>
)}
{mailboxes && <RelaySetCard label="Your Mailboxes" read={mailboxes.inbox} write={mailboxes.outbox} />}
{mailboxes && (
<Button variant="outline" colorScheme="primary" onClick={setRelaysToMailboxes}>
Use your existing relays ({RelaySet.from(mailboxes.inbox, mailboxes.outbox).urls.length})
</Button>
)}
<RelaySetCard label="Popular Relays" read={recommendedReadRelays} write={recommendedWriteRelays} />
<RelaySetCard label="Japanese relays" read={JapaneseRelays} write={JapaneseRelays} />
<Card w="full" variant="outline">
Expand Down

0 comments on commit e10dfe2

Please sign in to comment.