diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index ce0303d3..828fa438 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2677,7 +2677,7 @@ dependencies = [ [[package]] name = "lume" -version = "1.2.0" +version = "1.2.1" dependencies = [ "rust-argon2", "serde", diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json index 73bd8416..319abf8d 100644 --- a/src-tauri/tauri.linux.conf.json +++ b/src-tauri/tauri.linux.conf.json @@ -25,22 +25,6 @@ "hiddenTitle": true, "visible": false, "fileDropEnabled": true - }, - { - "width": 1080, - "height": 800, - "resizable": false, - "theme": "Dark", - "label": "settings", - "url": "settings", - "title": "Settings", - "titleBarStyle": "Overlay", - "transparent": false, - "center": true, - "fullscreen": false, - "hiddenTitle": true, - "visible": false, - "fileDropEnabled": false } ] } diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json index f24bb14a..07d2084a 100644 --- a/src-tauri/tauri.macos.conf.json +++ b/src-tauri/tauri.macos.conf.json @@ -32,26 +32,6 @@ "effects": ["hudWindow"], "state": "followsWindowActiveState" } - }, - { - "width": 1080, - "height": 800, - "resizable": false, - "theme": "Dark", - "label": "settings", - "url": "settings", - "title": "Settings", - "titleBarStyle": "Overlay", - "transparent": true, - "center": true, - "fullscreen": false, - "hiddenTitle": true, - "visible": false, - "fileDropEnabled": false, - "windowEffects": { - "effects": ["hudWindow"], - "state": "followsWindowActiveState" - } } ] } diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index 5e279375..9c0084d8 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -29,26 +29,6 @@ "effects": ["micaDark", "micaLight", "acrylic"], "state": "followsWindowActiveState" } - }, - { - "width": 1080, - "height": 800, - "resizable": false, - "theme": "Dark", - "label": "settings", - "url": "settings", - "title": "Settings", - "titleBarStyle": "Overlay", - "transparent": true, - "center": true, - "fullscreen": false, - "hiddenTitle": true, - "visible": false, - "fileDropEnabled": false, - "windowEffects": { - "effects": ["micaDark", "micaLight", "acrylic"], - "state": "followsWindowActiveState" - } } ] } diff --git a/src/app.tsx b/src/app.tsx index 3a319b92..9429edb9 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -110,6 +110,7 @@ const router = createBrowserRouter([ { path: '/auth', element: , + errorElement: , children: [ { path: 'welcome', @@ -121,6 +122,7 @@ const router = createBrowserRouter([ { path: 'import', element: , + errorElement: , children: [ { path: '', @@ -148,6 +150,7 @@ const router = createBrowserRouter([ { path: 'create', element: , + errorElement: , children: [ { path: '', @@ -175,6 +178,7 @@ const router = createBrowserRouter([ { path: 'onboarding', element: , + errorElement: , children: [ { path: '', @@ -232,23 +236,17 @@ const router = createBrowserRouter([ { path: '/settings', element: , + errorElement: , children: [ { - path: 'general', + path: '', async lazy() { const { GeneralSettingsScreen } = await import('@app/settings/general'); return { Component: GeneralSettingsScreen }; }, }, { - path: 'shortcuts', - async lazy() { - const { ShortcutsSettingsScreen } = await import('@app/settings/shortcuts'); - return { Component: ShortcutsSettingsScreen }; - }, - }, - { - path: 'account', + path: 'backup', async lazy() { const { AccountSettingsScreen } = await import('@app/settings/account'); return { Component: AccountSettingsScreen }; diff --git a/src/app/chats/components/list.tsx b/src/app/chats/components/list.tsx index 450fd064..c40ea7ad 100644 --- a/src/app/chats/components/list.tsx +++ b/src/app/chats/components/list.tsx @@ -32,11 +32,11 @@ export function ChatsList() { if (status === 'loading') { return (
-
+
-
+
diff --git a/src/app/settings/account.tsx b/src/app/settings/account.tsx index acc4def4..c6e5df43 100644 --- a/src/app/settings/account.tsx +++ b/src/app/settings/account.tsx @@ -1,4 +1,5 @@ -import { useState } from 'react'; +import { nip19 } from 'nostr-tools'; +import { useMemo, useState } from 'react'; import { useStorage } from '@libs/storage/provider'; @@ -7,84 +8,119 @@ import { EyeOffIcon, EyeOnIcon } from '@shared/icons'; import { useStronghold } from '@stores/stronghold'; export function AccountSettingsScreen() { - const [type, setType] = useState('password'); - const privkey = useStronghold((state) => state.privkey); const { db } = useStorage(); - const showPrivateKey = () => { - if (type === 'password') { - setType('text'); + const [privType, setPrivType] = useState('password'); + const [nsecType, setNsecType] = useState('password'); + + const privkey = useStronghold((state) => state.privkey); + const nsec = useMemo(() => nip19.nsecEncode(privkey), [privkey]); + + const showPrivkey = () => { + if (privType === 'password') { + setPrivType('text'); } else { - setType('password'); + setPrivType('password'); + } + }; + + const showNsec = () => { + if (nsecType === 'password') { + setNsecType('text'); + } else { + setNsecType('password'); } }; return ( -
+
-

Account

-
- {status === 'loading' ? ( -

Loading...

- ) : ( -
-
- - -
-
- - -
-
- -
- Account +
+
+ + +
+
+ + +
+
+ +
+ + -
-
+ ) : ( + + )} +
- )} +
+
+ +
+ + +
+
diff --git a/src/app/settings/components/dataPath.tsx b/src/app/settings/components/dataPath.tsx new file mode 100644 index 00000000..bf980d4b --- /dev/null +++ b/src/app/settings/components/dataPath.tsx @@ -0,0 +1,28 @@ +import { appConfigDir } from '@tauri-apps/api/path'; +import { useEffect, useState } from 'react'; + +export function DataPath() { + const [path, setPath] = useState(''); + + useEffect(() => { + async function getPath() { + const dir = await appConfigDir(); + setPath(dir); + } + getPath(); + }, []); + + return ( +
+
+ App data path + + Where the local data is stored + +
+
+ {path} +
+
+ ); +} diff --git a/src/app/settings/components/version.tsx b/src/app/settings/components/version.tsx index 0aed8bcf..3a6cddbd 100644 --- a/src/app/settings/components/version.tsx +++ b/src/app/settings/components/version.tsx @@ -1,8 +1,6 @@ import { getVersion } from '@tauri-apps/plugin-app'; import { useEffect, useState } from 'react'; -import { RefreshIcon } from '@shared/icons'; - export function VersionSetting() { const [version, setVersion] = useState(''); @@ -24,12 +22,6 @@ export function VersionSetting() {
{version} -
); diff --git a/src/app/settings/general.tsx b/src/app/settings/general.tsx index 89a06422..75b602df 100644 --- a/src/app/settings/general.tsx +++ b/src/app/settings/general.tsx @@ -1,16 +1,16 @@ import { AutoStartSetting } from '@app/settings/components/autoStart'; -import { CacheTimeSetting } from '@app/settings/components/cacheTime'; +import { DataPath } from '@app/settings/components/dataPath'; import { VersionSetting } from '@app/settings/components/version'; export function GeneralSettingsScreen() { return ( -
+
-

General

+

General

- +
diff --git a/src/app/space/components/widgetList.tsx b/src/app/space/components/widgetList.tsx index 477e3d46..ac049729 100644 --- a/src/app/space/components/widgetList.tsx +++ b/src/app/space/components/widgetList.tsx @@ -42,7 +42,7 @@ export function WidgetList({ params }: { params: Widget }) { return (
- +
{DefaultWidgets.map((row: WidgetGroup) => renderItem(row))}
diff --git a/src/libs/ndk/instance.ts b/src/libs/ndk/instance.ts index fbba215a..16cf5d09 100644 --- a/src/libs/ndk/instance.ts +++ b/src/libs/ndk/instance.ts @@ -58,7 +58,7 @@ export const NDKInstance = () => { // return all validate relays return verifiedRelays; } catch (e) { - e.forEach((error) => console.error(error)); + console.error('ndk instance error: ', e); } } diff --git a/src/shared/accounts/active.tsx b/src/shared/accounts/active.tsx index d515352c..74cf4e89 100644 --- a/src/shared/accounts/active.tsx +++ b/src/shared/accounts/active.tsx @@ -1,14 +1,15 @@ import { NDKFilter, NDKKind } from '@nostr-dev-kit/ndk'; import { useEffect } from 'react'; -import { Link } from 'react-router-dom'; import { useStorage } from '@libs/storage/provider'; +import { AccountMoreActions } from '@shared/accounts/more'; import { Image } from '@shared/image'; import { useNostr } from '@utils/hooks/useNostr'; import { useProfile } from '@utils/hooks/useProfile'; import { sendNativeNotification } from '@utils/notification'; +import { displayNpub } from '@utils/shortenKey'; export function ActiveAccount() { const { db } = useStorage(); @@ -57,16 +58,23 @@ export function ActiveAccount() { } return ( - - {db.account.npub} -

Your profile

- +
+
+ {db.account.npub} +
+

+ {user?.name || user?.display_name || user?.nip05} +

+ + {displayNpub(db.account.pubkey, 16)} + +
+
+ +
); } diff --git a/src/shared/accounts/inactive.tsx b/src/shared/accounts/inactive.tsx deleted file mode 100644 index dd7275af..00000000 --- a/src/shared/accounts/inactive.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Image } from '@shared/image'; - -import { useProfile } from '@utils/hooks/useProfile'; - -export function InactiveAccount({ data }: { data: any }) { - const { user } = useProfile(data.npub); - - return ( -
- {data.npub} -
- ); -} diff --git a/src/shared/accounts/more.tsx b/src/shared/accounts/more.tsx new file mode 100644 index 00000000..e49158ca --- /dev/null +++ b/src/shared/accounts/more.tsx @@ -0,0 +1,55 @@ +import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; +import { useState } from 'react'; +import { Link } from 'react-router-dom'; + +import { HorizontalDotsIcon } from '@shared/icons'; + +export function AccountMoreActions({ pubkey }: { pubkey: string }) { + const [open, setOpen] = useState(false); + + return ( + + + + + + + + + Profile + + + + + Backup + + + + + Settings + + + + + + + + + ); +} diff --git a/src/shared/icons/index.ts b/src/shared/icons/index.ts index fb2ee072..b295e50b 100644 --- a/src/shared/icons/index.ts +++ b/src/shared/icons/index.ts @@ -55,3 +55,4 @@ export * from './share'; export * from './expand'; export * from './focus'; export * from './chevronUp'; +export * from './secure'; diff --git a/src/shared/icons/secure.tsx b/src/shared/icons/secure.tsx new file mode 100644 index 00000000..0769ff01 --- /dev/null +++ b/src/shared/icons/secure.tsx @@ -0,0 +1,22 @@ +import { SVGProps } from 'react'; + +export function SecureIcon(props: JSX.IntrinsicAttributes & SVGProps) { + return ( + + + + ); +} diff --git a/src/shared/layouts/settings.tsx b/src/shared/layouts/settings.tsx index 89a0823b..d6df0c4d 100644 --- a/src/shared/layouts/settings.tsx +++ b/src/shared/layouts/settings.tsx @@ -1,60 +1,58 @@ -import { NavLink, Outlet, ScrollRestoration } from 'react-router-dom'; +import { Link, NavLink, Outlet, ScrollRestoration } from 'react-router-dom'; import { twMerge } from 'tailwind-merge'; +import { ArrowLeftIcon, SecureIcon, SettingsIcon } from '@shared/icons'; + export function SettingsLayout() { return (
-
-
-
-
-
-

- Settings -

-
-
- - twMerge( - 'flex h-9 items-center gap-2.5 rounded-md px-2.5', - isActive - ? 'bg-white/10 text-white backdrop-blur-xl' - : 'text-white/80' - ) - } - > - General - - - twMerge( - 'flex h-9 items-center gap-2.5 rounded-md px-2.5', - isActive - ? 'bg-white/10 text-white backdrop-blur-xl' - : 'text-white/80' - ) - } - > - Shortcuts - - - twMerge( - 'flex h-9 items-center gap-2.5 rounded-md px-2.5', - isActive - ? 'bg-white/10 text-white backdrop-blur-xl' - : 'text-white/80' - ) - } - > - Account - -
-
+
+
+
+
+ + + +

+ Settings +

+
+
+ + twMerge( + 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-2', + isActive + ? 'border-fuchsia-500 bg-white/5 text-white' + : 'border-transparent text-white/80' + ) + } + > + + + + General + + + twMerge( + 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-2', + isActive + ? 'border-fuchsia-500 bg-white/5 text-white' + : 'border-transparent text-white/80' + ) + } + > + + + + Backup +
diff --git a/src/shared/navigation.tsx b/src/shared/navigation.tsx index ee8d62da..5f6f8500 100644 --- a/src/shared/navigation.tsx +++ b/src/shared/navigation.tsx @@ -6,7 +6,7 @@ import { ChatsList } from '@app/chats/components/list'; import { ActiveAccount } from '@shared/accounts/active'; import { ComposerModal } from '@shared/composer'; -import { BellIcon, NavArrowDownIcon, SettingsIcon, SpaceIcon } from '@shared/icons'; +import { BellIcon, NavArrowDownIcon, SpaceIcon } from '@shared/icons'; import { useSidebar } from '@stores/sidebar'; @@ -14,9 +14,9 @@ export function Navigation() { const [chats, toggleChats] = useSidebar((state) => [state.chats, state.toggleChats]); return ( -
-
-
+
+
+
Notifications - - twMerge( - 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-2', - isActive - ? 'border-fuchsia-500 bg-white/5 text-white' - : 'border-transparent text-white/80' - ) - } - > - - - - Settings - -
@@ -95,6 +77,9 @@ export function Navigation() {
+
+ +
); } diff --git a/src/shared/notes/actions/more.tsx b/src/shared/notes/actions/more.tsx index 2c7e7afd..ca7c1591 100644 --- a/src/shared/notes/actions/more.tsx +++ b/src/shared/notes/actions/more.tsx @@ -45,7 +45,7 @@ export function MoreActions({ id, pubkey }: { id: string; pubkey: string }) { - +