From 773e49afa247aed3c563c424f3037c0ebbaef3f0 Mon Sep 17 00:00:00 2001 From: reya Date: Wed, 15 Nov 2023 13:13:11 +0700 Subject: [PATCH] wip --- src-tauri/tauri.conf.json | 2 +- src/app.tsx | 11 +- src/app/settings/account.tsx | 138 ---------------------- src/app/settings/components/autoStart.tsx | 12 -- src/app/settings/components/cacheTime.tsx | 40 ------- src/app/settings/components/dataPath.tsx | 28 ----- src/app/settings/components/version.tsx | 15 --- src/app/settings/general.tsx | 20 ---- src/app/settings/index.tsx | 3 + src/app/settings/shortcuts.tsx | 118 ------------------ src/shared/accounts/more.tsx | 12 +- src/shared/layouts/settings.tsx | 73 ++---------- src/shared/logout.tsx | 4 +- src/shared/notes/actions/zap.tsx | 48 ++++---- 14 files changed, 49 insertions(+), 475 deletions(-) delete mode 100644 src/app/settings/account.tsx delete mode 100644 src/app/settings/components/autoStart.tsx delete mode 100644 src/app/settings/components/cacheTime.tsx delete mode 100644 src/app/settings/components/dataPath.tsx delete mode 100644 src/app/settings/components/version.tsx delete mode 100644 src/app/settings/general.tsx create mode 100644 src/app/settings/index.tsx delete mode 100644 src/app/settings/shortcuts.tsx diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f3aa89ee..81b9971f 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -60,7 +60,7 @@ ], "copyright": "", "identifier": "com.lume.nu", - "longDescription": "", + "longDescription": "The communication app build on Nostr Protocol", "shortDescription": "", "targets": "all", "updater": { diff --git a/src/app.tsx b/src/app.tsx index 57643ed3..bdc93bd4 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -260,15 +260,8 @@ export default function App() { { path: '', async lazy() { - const { GeneralSettingsScreen } = await import('@app/settings/general'); - return { Component: GeneralSettingsScreen }; - }, - }, - { - path: 'backup', - async lazy() { - const { AccountSettingsScreen } = await import('@app/settings/account'); - return { Component: AccountSettingsScreen }; + const { SettingsScreen } = await import('@app/settings'); + return { Component: SettingsScreen }; }, }, ], diff --git a/src/app/settings/account.tsx b/src/app/settings/account.tsx deleted file mode 100644 index 5c20bc6f..00000000 --- a/src/app/settings/account.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { nip19 } from 'nostr-tools'; -import { useMemo, useState } from 'react'; - -import { useStorage } from '@libs/storage/provider'; - -import { EyeOffIcon, EyeOnIcon } from '@shared/icons'; - -export function AccountSettingsScreen() { - const { db } = useStorage(); - - const [privType, setPrivType] = useState('password'); - const [nsecType, setNsecType] = useState('password'); - - const privkey = 'todo'; - const nsec = useMemo(() => nip19.nsecEncode(privkey), [privkey]); - - const showPrivkey = () => { - if (privType === 'password') { - setPrivType('text'); - } else { - setPrivType('password'); - } - }; - - const showNsec = () => { - if (nsecType === 'password') { - setNsecType('text'); - } else { - setNsecType('password'); - } - }; - - return ( -
-
-

Account

-
-
- - -
-
- - -
-
- -
- - -
-
-
- -
- - -
-
-
-
-
- ); -} diff --git a/src/app/settings/components/autoStart.tsx b/src/app/settings/components/autoStart.tsx deleted file mode 100644 index 5a71136d..00000000 --- a/src/app/settings/components/autoStart.tsx +++ /dev/null @@ -1,12 +0,0 @@ -export function AutoStartSetting() { - return ( -
-
- Auto start - - Auto start at login - -
-
- ); -} diff --git a/src/app/settings/components/cacheTime.tsx b/src/app/settings/components/cacheTime.tsx deleted file mode 100644 index 2e9b06a5..00000000 --- a/src/app/settings/components/cacheTime.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { useState } from 'react'; - -import { CheckCircleIcon } from '@shared/icons'; - -export function CacheTimeSetting() { - const [time, setTime] = useState('0'); - - const update = async () => { - // await updateSetting('cache_time', time); - }; - - return ( -
-
- - Cache time (milliseconds) - - - The length of time before inactive data gets removed from the cache - -
-
- setTime(e.currentTarget.value)} - autoCapitalize="none" - autoCorrect="none" - className="h-8 w-24 rounded-md bg-neutral-800 px-2 text-right font-medium text-neutral-300 focus:outline-none" - /> - -
-
- ); -} diff --git a/src/app/settings/components/dataPath.tsx b/src/app/settings/components/dataPath.tsx deleted file mode 100644 index 6308a930..00000000 --- a/src/app/settings/components/dataPath.tsx +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index ac5ac2ac..00000000 --- a/src/app/settings/components/version.tsx +++ /dev/null @@ -1,15 +0,0 @@ -export function VersionSetting() { - return ( -
-
- Version - - You're using latest version - -
-
- 2 -
-
- ); -} diff --git a/src/app/settings/general.tsx b/src/app/settings/general.tsx deleted file mode 100644 index 4d2f8b4e..00000000 --- a/src/app/settings/general.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { AutoStartSetting } from '@app/settings/components/autoStart'; -import { DataPath } from '@app/settings/components/dataPath'; -import { VersionSetting } from '@app/settings/components/version'; - -export function GeneralSettingsScreen() { - return ( -
-
-

General

-
-
- - - -
-
-
-
- ); -} diff --git a/src/app/settings/index.tsx b/src/app/settings/index.tsx new file mode 100644 index 00000000..93ea91e9 --- /dev/null +++ b/src/app/settings/index.tsx @@ -0,0 +1,3 @@ +export function SettingsScreen() { + return
; +} diff --git a/src/app/settings/shortcuts.tsx b/src/app/settings/shortcuts.tsx deleted file mode 100644 index 73b89561..00000000 --- a/src/app/settings/shortcuts.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import { CommandIcon } from '@shared/icons'; - -export function ShortcutsSettingsScreen() { - return ( -
-
-

Shortcuts

-
-
-
-
- Open composer -
-
-
- -
-
- - N - -
-
-
-
-
- - Add image block - -
-
-
- -
-
- - I - -
-
-
-
-
- - Add newsfeed block - -
-
-
- -
-
- - F - -
-
-
-
-
- - Open personal page - -
-
-
- -
-
- - P - -
-
-
-
-
- - Open notification - -
-
-
- -
-
- - B - -
-
-
-
-
-
-
- ); -} diff --git a/src/shared/accounts/more.tsx b/src/shared/accounts/more.tsx index 206d9851..c541d9c1 100644 --- a/src/shared/accounts/more.tsx +++ b/src/shared/accounts/more.tsx @@ -1,8 +1,6 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; import { Link } from 'react-router-dom'; -import { useStorage } from '@libs/storage/provider'; - import { HorizontalDotsIcon } from '@shared/icons'; import { Logout } from '@shared/logout'; @@ -21,21 +19,23 @@ export function AccountMoreActions() { - Backup + Dashboard Settings - + + + diff --git a/src/shared/layouts/settings.tsx b/src/shared/layouts/settings.tsx index f15db081..1c3e5d57 100644 --- a/src/shared/layouts/settings.tsx +++ b/src/shared/layouts/settings.tsx @@ -1,68 +1,21 @@ -import { Link, NavLink, Outlet, ScrollRestoration } from 'react-router-dom'; -import { twMerge } from 'tailwind-merge'; +import { Outlet, ScrollRestoration } from 'react-router-dom'; +import { WindowTitlebar } from 'tauri-controls'; -import { ArrowLeftIcon, SecureIcon, SettingsIcon } from '@shared/icons'; +import { useStorage } from '@libs/storage/provider'; export function SettingsLayout() { + const { db } = useStorage(); + return ( -
-
-
-
-
- - - -

- Settings -

-
-
- - twMerge( - 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-2', - isActive - ? 'border-blue-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-blue-500 bg-white/5 text-white' - : 'border-transparent text-white/80' - ) - } - > - - - - Backup - -
-
-
-
+
+ {db.platform !== 'macos' ? ( + + ) : ( +
+ )} +
- { - return location.pathname; - }} - /> +
); diff --git a/src/shared/logout.tsx b/src/shared/logout.tsx index 54eb8d1d..da489ee1 100644 --- a/src/shared/logout.tsx +++ b/src/shared/logout.tsx @@ -5,11 +5,11 @@ import { useNDK } from '@libs/ndk/provider'; import { useStorage } from '@libs/storage/provider'; export function Logout() { - const navigate = useNavigate(); - const { db } = useStorage(); const { ndk } = useNDK(); + const navigate = useNavigate(); + const logout = async () => { ndk.signer = null; diff --git a/src/shared/notes/actions/zap.tsx b/src/shared/notes/actions/zap.tsx index 0adebd5d..f5c2a6e8 100644 --- a/src/shared/notes/actions/zap.tsx +++ b/src/shared/notes/actions/zap.tsx @@ -80,9 +80,7 @@ export function NoteZap({ event }: { event: NDKEvent }) { if (uri) setWalletConnectURL(uri); } - if (isOpen) { - getWalletConnectURL(); - } + if (isOpen) getWalletConnectURL(); return () => { setAmount('21'); @@ -103,16 +101,16 @@ export function NoteZap({ event }: { event: NDKEvent }) { - + -
+
- + Send tip to {user?.name || user?.display_name || user?.displayName} - - + +
@@ -129,7 +127,7 @@ export function NoteZap({ event }: { event: NDKEvent }) { max={10000} // 1M sats maxLength={10000} // 1M sats onValueChange={(value) => setAmount(value)} - className="w-full flex-1 bg-transparent text-right text-4xl font-semibold text-white placeholder:text-neutral-600 focus:outline-none dark:text-neutral-400" + className="w-full flex-1 bg-transparent text-right text-4xl font-semibold placeholder:text-neutral-600 focus:outline-none dark:text-neutral-400" /> sats @@ -139,35 +137,35 @@ export function NoteZap({ event }: { event: NDKEvent }) { @@ -183,28 +181,28 @@ export function NoteZap({ event }: { event: NDKEvent }) { autoCorrect="off" autoCapitalize="off" placeholder="Enter message (optional)" - className="relative min-h-[56px] w-full resize-none rounded-lg bg-white/10 px-3 py-2 !outline-none backdrop-blur-xl placeholder:text-neutral-600 dark:text-neutral-400" + className="w-full resize-none rounded-lg bg-neutral-100 px-3 py-3 !outline-none placeholder:text-neutral-600 dark:bg-neutral-900 dark:text-neutral-400" />
{walletConnectURL ? ( )}
@@ -224,13 +222,11 @@ export function NoteZap({ event }: { event: NDKEvent }) { ) : (
-
+
-

- Scan to pay -

+

Scan to pay

You must use Bitcoin wallet which support Lightning