diff --git a/.changeset/lovely-needles-invite.md b/.changeset/lovely-needles-invite.md new file mode 100644 index 000000000..5004b4e5a --- /dev/null +++ b/.changeset/lovely-needles-invite.md @@ -0,0 +1,5 @@ +--- +"nostrudel": minor +--- + +Rebuilt settings view tabs diff --git a/src/app.tsx b/src/app.tsx index c8b3b01b2..6de32873f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -97,6 +97,11 @@ const VideoDetailsView = lazy(() => import("./views/videos/video")); import BookmarksView from "./views/bookmarks"; import TaskManagerProvider from "./views/task-manager/provider"; import SearchRelaysView from "./views/relays/search"; +import DisplaySettings from "./views/settings/display"; +import LightningSettings from "./views/settings/lightning"; +import PerformanceSettings from "./views/settings/performance"; +import PrivacySettings from "./views/settings/privacy"; +import PostSettings from "./views/settings/post"; const TracksView = lazy(() => import("./views/tracks")); const UserTracksTab = lazy(() => import("./views/user/tracks")); const UserVideosTab = lazy(() => import("./views/user/videos")); @@ -254,7 +259,18 @@ const router = createHashRouter([ element: , }, { path: "other-stuff", element: }, - { path: "settings", element: }, + { + path: "settings", + element: , + children: [ + { path: "", element: }, + { path: "post", element: }, + { path: "display", element: }, + { path: "privacy", element: }, + { path: "lightning", element: }, + { path: "performance", element: }, + ], + }, { path: "relays", element: , diff --git a/src/components/simple-nav-item.tsx b/src/components/simple-nav-item.tsx new file mode 100644 index 000000000..6a2f81a3b --- /dev/null +++ b/src/components/simple-nav-item.tsx @@ -0,0 +1,23 @@ +import { Button, ButtonProps } from "@chakra-ui/react"; +import { useMatch, Link as RouterLink } from "react-router-dom"; + +export default function SimpleNavItem({ + children, + to, + ...props +}: Omit & { to: string }) { + const match = useMatch(to); + + return ( + + ); +} diff --git a/src/views/relays/index.tsx b/src/views/relays/index.tsx index 73ea8c735..5df3be093 100644 --- a/src/views/relays/index.tsx +++ b/src/views/relays/index.tsx @@ -1,5 +1,5 @@ -import { Outlet, Link as RouterLink, useLocation } from "react-router-dom"; -import { Button, Flex, Spinner } from "@chakra-ui/react"; +import { Outlet, useLocation } from "react-router-dom"; +import { Flex, Spinner } from "@chakra-ui/react"; import VerticalPageLayout from "../../components/vertical-page-layout"; import useCurrentAccount from "../../hooks/use-current-account"; @@ -14,6 +14,7 @@ import UserSquare from "../../components/icons/user-square"; import Image01 from "../../components/icons/image-01"; import Server05 from "../../components/icons/server-05"; import { Suspense } from "react"; +import SimpleNavItem from "../../components/simple-nav-item"; export default function RelaysView() { const account = useCurrentAccount(); @@ -27,90 +28,38 @@ export default function RelaysView() { const renderContent = () => { const nav = ( - - + {account && ( <> - - - + )} - + {nip05?.exists && ( - + )} {account && ( <> - + )} {/* {account && ( @@ -132,6 +81,7 @@ export default function RelaysView() { )} */} ); + if (vertical) { if (location.pathname !== "/relays") return ; else return nav; diff --git a/src/views/settings/database-settings.tsx b/src/views/settings/database-settings.tsx deleted file mode 100644 index 413c54e48..000000000 --- a/src/views/settings/database-settings.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { useState } from "react"; -import { useAsync } from "react-use"; -import { - Button, - AccordionItem, - AccordionPanel, - AccordionButton, - Box, - AccordionIcon, - Text, - Flex, -} from "@chakra-ui/react"; -import { countEvents, countEventsByKind } from "nostr-idb"; -import { Link as RouterLink } from "react-router-dom"; - -import { clearCacheData, deleteDatabase } from "../../services/db"; -import { DatabaseIcon } from "../../components/icons"; -import { localDatabase } from "../../services/local-relay"; - -function DatabaseStats() { - const { value: count } = useAsync(async () => await countEvents(localDatabase), []); - const { value: kinds } = useAsync(async () => await countEventsByKind(localDatabase), []); - - return ( - <> - {count} cached events - - {Object.entries(kinds || {}) - .map(([kind, count]) => `${kind} (${count})`) - .join(", ")} - - - ); -} - -export default function DatabaseSettings() { - const [clearing, setClearing] = useState(false); - const handleClearData = async () => { - setClearing(true); - await clearCacheData(); - setClearing(false); - }; - - const [deleting, setDeleting] = useState(false); - const handleDeleteDatabase = async () => { - setDeleting(true); - await deleteDatabase(); - setDeleting(false); - }; - - return ( - -

- - - - Database - - - -

- - Database tools have moved - - -
- ); -} diff --git a/src/views/settings/display-settings.tsx b/src/views/settings/display-settings.tsx deleted file mode 100644 index aac1b0f3c..000000000 --- a/src/views/settings/display-settings.tsx +++ /dev/null @@ -1,190 +0,0 @@ -import { useFormContext } from "react-hook-form"; -import { Link as RouterLink } from "react-router-dom"; -import { - Flex, - FormControl, - FormLabel, - Switch, - AccordionItem, - AccordionPanel, - AccordionButton, - Box, - AccordionIcon, - FormHelperText, - Input, - Select, - Textarea, - Link, -} from "@chakra-ui/react"; - -import { AppSettings } from "../../services/settings/migrations"; -import { AppearanceIcon } from "../../components/icons"; -import useSubject from "../../hooks/use-subject"; -import localSettings from "../../services/local-settings"; - -export default function DisplaySettings() { - const { register } = useFormContext(); - - const hideZapBubbles = useSubject(localSettings.hideZapBubbles); - const enableNoteDrawer = useSubject(localSettings.enableNoteThreadDrawer); - - return ( - -

- - - - Display - - - -

- - - - - Theme - - - - - - Color Mode - - - - - - - Primary Color - - - - - - - Max Page width - - - - Setting this will restrict the width of app on desktop - - - - - - Blur media from strangers - - - - - Enabled: blur media from people you aren't following - - - - - - Hide usernames (anon mode) - - - - - - Enabled: hides usernames and pictures.{" "} - - Details - - - - - - - - Hide Emojis in usernames - - - - - Enabled: Removes all emojis in other users usernames and display names - - - - - - Hide individual zaps on notes - - localSettings.hideZapBubbles.next(!localSettings.hideZapBubbles.value)} - /> - - - Enabled: Hides individual zaps on notes in the timeline - - - - - - Show content warning - - - - - Enabled: shows a warning for notes with NIP-36 Content Warning - - - - - - Open embedded notes in side drawer - - localSettings.enableNoteThreadDrawer.next(!localSettings.enableNoteThreadDrawer.value)} - /> - - - Enabled: Clicking on an embedded note will open it in a side drawer - - - - - Muted words - -