diff --git a/.changeset/metal-laws-relate.md b/.changeset/metal-laws-relate.md new file mode 100644 index 000000000..190a6deb9 --- /dev/null +++ b/.changeset/metal-laws-relate.md @@ -0,0 +1,5 @@ +--- +"nostrudel": minor +--- + +Add default auth options to task manager and app relays views diff --git a/src/components/settings/default-auth-mode-select.tsx b/src/components/settings/default-auth-mode-select.tsx new file mode 100644 index 000000000..0dbadbc50 --- /dev/null +++ b/src/components/settings/default-auth-mode-select.tsx @@ -0,0 +1,21 @@ +import { Select, SelectProps } from "@chakra-ui/react"; +import { useObservable } from "applesauce-react/hooks"; + +import localSettings from "../../services/local-settings"; +import { RelayAuthMode } from "../../classes/relay-pool"; + +export default function DefaultAuthModeSelect({ ...props }: Omit) { + const defaultAuthenticationMode = useObservable(localSettings.defaultAuthenticationMode); + + return ( + + ); +} diff --git a/src/views/relays/app/index.tsx b/src/views/relays/app/index.tsx index f0f493967..0797babfe 100644 --- a/src/views/relays/app/index.tsx +++ b/src/views/relays/app/index.tsx @@ -1,5 +1,17 @@ import { MouseEventHandler, useCallback, useMemo } from "react"; -import { Button, Card, CardBody, CardHeader, Flex, Heading, SimpleGrid, Text } from "@chakra-ui/react"; +import { + Button, + Card, + CardBody, + CardHeader, + Flex, + Heading, + Select, + SimpleGrid, + Switch, + Text, + Tooltip, +} from "@chakra-ui/react"; import { kinds } from "nostr-tools"; import { WarningIcon } from "@chakra-ui/icons"; import { useObservable } from "applesauce-react/hooks"; @@ -22,6 +34,10 @@ import SelectRelaySet from "./select-relay-set"; import { safeRelayUrls } from "../../../helpers/relay"; import HoverLinkOverlay from "../../../components/hover-link-overlay"; import useReplaceableEvent from "../../../hooks/use-replaceable-event"; +import localSettings from "../../../services/local-settings"; +import { RelayAuthMode } from "../../../classes/relay-pool"; +import DefaultAuthModeSelect from "../../../components/settings/default-auth-mode-select"; +import HelpCircle from "../../../components/icons/help-circle"; const JapaneseRelays = safeRelayUrls([ "wss://r.kojira.io", @@ -70,6 +86,8 @@ export default function AppRelays() { const sorted = useMemo(() => RelaySet.from(readRelays, writeRelays).urls.sort(), [readRelays, writeRelays]); + const proactivelyAuthenticate = useObservable(localSettings.proactivelyAuthenticate); + return ( @@ -107,7 +125,31 @@ export default function AppRelays() { )} - Set from: + Authentication + + + + + Default: + + + + localSettings.proactivelyAuthenticate.next(e.currentTarget.checked)} + /> + + Proactively authenticate + + + + + + + + Set from {window.nostr && ( @@ -164,7 +206,7 @@ export default function AppRelays() { )} - Presets: + Presets diff --git a/src/views/settings/privacy/index.tsx b/src/views/settings/privacy/index.tsx index 110db4035..c8fa0d9e8 100644 --- a/src/views/settings/privacy/index.tsx +++ b/src/views/settings/privacy/index.tsx @@ -7,7 +7,6 @@ import { FormErrorMessage, Code, Switch, - Select, Button, Heading, FormLabel, @@ -17,10 +16,10 @@ import { useObservable } from "applesauce-react/hooks"; import { safeUrl } from "../../../helpers/parse"; import { createRequestProxyUrl } from "../../../helpers/request"; -import { RelayAuthMode } from "../../../classes/relay-pool"; import VerticalPageLayout from "../../../components/vertical-page-layout"; import useSettingsForm from "../use-settings-form"; import localSettings from "../../../services/local-settings"; +import DefaultAuthModeSelect from "../../../components/settings/default-auth-mode-select"; async function validateInvidiousUrl(url?: string) { if (!url) return true; @@ -47,7 +46,6 @@ async function validateRequestProxy(url?: string) { export default function PrivacySettings() { const { register, submit, formState } = useSettingsForm(); - const defaultAuthenticationMode = useObservable(localSettings.defaultAuthenticationMode); const proactivelyAuthenticate = useObservable(localSettings.proactivelyAuthenticate); const debugApi = useObservable(localSettings.debugApi); @@ -57,17 +55,7 @@ export default function PrivacySettings() { Default authorization behavior - + How should the app handle relays requesting identification diff --git a/src/views/task-manager/relays/index.tsx b/src/views/task-manager/relays/index.tsx index 92ce5a08c..76ab57c01 100644 --- a/src/views/task-manager/relays/index.tsx +++ b/src/views/task-manager/relays/index.tsx @@ -3,11 +3,15 @@ import { Badge, Box, Flex, + FormControl, + FormHelperText, + FormLabel, Link, LinkBox, Select, SimpleGrid, Spacer, + Switch, Tab, TabIndicator, TabList, @@ -35,6 +39,7 @@ import { RelayAuthMode } from "../../../classes/relay-pool"; import Timestamp from "../../../components/timestamp"; import localSettings from "../../../services/local-settings"; import useForceUpdate from "../../../hooks/use-force-update"; +import DefaultAuthModeSelect from "../../../components/settings/default-auth-mode-select"; function RelayCard({ relay }: { relay: AbstractRelay }) { return ( @@ -118,6 +123,8 @@ export default function TaskManagerRelays() { const challenges = Array.from(relayPoolService.challenges.entries()).filter(([r, c]) => r.connected && !!c.value); + const proactivelyAuthenticate = useObservable(localSettings.proactivelyAuthenticate); + return ( setTab(TABS[i])} isLazy> @@ -137,6 +144,22 @@ export default function TaskManagerRelays() { + + + Default: + + + + localSettings.proactivelyAuthenticate.next(e.currentTarget.checked)} + /> + + Proactively authenticate + + {challenges.map(([relay, challenge]) => (