From 8aa2ef39c5a4d34c52ae5c795c80df27053694f4 Mon Sep 17 00:00:00 2001 From: reya Date: Thu, 2 Nov 2023 13:47:44 +0700 Subject: [PATCH] update nip-05 and user profile component styles --- src-tauri/src/main.rs | 7 ------ src/app.tsx | 7 ++++++ src/app/personal/index.tsx | 9 ++++++++ src/app/users/components/profile.tsx | 30 +++++++++++++++++++------ src/app/users/components/stats.tsx | 13 ++++++++--- src/app/users/index.tsx | 1 - src/shared/accounts/active.tsx | 6 ++--- src/shared/accounts/more.tsx | 17 ++++---------- src/shared/nip05.tsx | 26 +++++++++++++--------- src/shared/widgets/newsfeed.tsx | 33 ++++++++++++++-------------- src/shared/widgets/notification.tsx | 4 ++++ 11 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 src/app/personal/index.tsx diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 34938251..7aa4068e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,7 +5,6 @@ use keyring::Entry; use std::time::Duration; -use tauri::Manager; use tauri_plugin_autostart::MacosLauncher; use tauri_plugin_sql::{Migration, MigrationKind}; use webpage::{Webpage, WebpageOptions}; @@ -149,12 +148,6 @@ fn main() { MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]), )) - .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { - println!("{}, {argv:?}, {cwd}", app.package_info().name); - app - .emit_all("single-instance", Payload { args: argv, cwd }) - .unwrap(); - })) .plugin(tauri_plugin_upload::init()) .plugin(tauri_plugin_store::Builder::default().build()) .invoke_handler(tauri::generate_handler![ diff --git a/src/app.tsx b/src/app.tsx index 62edb50a..80c86abb 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -110,6 +110,13 @@ export default function App() { }, ], }, + { + path: 'personal', + async lazy() { + const { PersonalScreen } = await import('@app/personal'); + return { Component: PersonalScreen }; + }, + }, ], }, { diff --git a/src/app/personal/index.tsx b/src/app/personal/index.tsx new file mode 100644 index 00000000..c6dc0404 --- /dev/null +++ b/src/app/personal/index.tsx @@ -0,0 +1,9 @@ +import { useStorage } from '@libs/storage/provider'; + +import { UserProfile } from '@shared/userProfile'; + +export function PersonalScreen() { + const { db } = useStorage(); + + return
; +} diff --git a/src/app/users/components/profile.tsx b/src/app/users/components/profile.tsx index c92fe0c8..cbca16e0 100644 --- a/src/app/users/components/profile.tsx +++ b/src/app/users/components/profile.tsx @@ -1,4 +1,6 @@ import { NDKEvent, NDKKind, NDKUser } from '@nostr-dev-kit/ndk'; +import * as Avatar from '@radix-ui/react-avatar'; +import { minidenticon } from 'minidenticons'; import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { toast } from 'sonner'; @@ -9,7 +11,6 @@ import { UserStats } from '@app/users/components/stats'; import { useNDK } from '@libs/ndk/provider'; import { useStorage } from '@libs/storage/provider'; -import { Image } from '@shared/image'; import { NIP05 } from '@shared/nip05'; import { useProfile } from '@utils/hooks/useProfile'; @@ -22,6 +23,9 @@ export function UserProfile({ pubkey }: { pubkey: string }) { const [followed, setFollowed] = useState(false); + const svgURI = + 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(pubkey, 90, 50)); + const follow = async (pubkey: string) => { try { const user = ndk.getUser({ hexpubkey: db.account.pubkey }); @@ -85,11 +89,23 @@ export function UserProfile({ pubkey }: { pubkey: string }) { )}
- {pubkey} + + + + {pubkey} + +
@@ -100,7 +116,7 @@ export function UserProfile({ pubkey }: { pubkey: string }) { ) : ( diff --git a/src/app/users/components/stats.tsx b/src/app/users/components/stats.tsx index a2c99998..f03d559b 100644 --- a/src/app/users/components/stats.tsx +++ b/src/app/users/components/stats.tsx @@ -6,15 +6,22 @@ import { compactNumber } from '@utils/number'; export function UserStats({ pubkey }: { pubkey: string }) { const { status, data } = useQuery({ - queryKey: ['user-metadata', pubkey], + queryKey: ['user-stats', pubkey], + queryFn: async ({ signal }: { signal: AbortSignal }) => { + const res = await fetch(`https://api.nostr.band/v0/stats/profile/${pubkey}`, { + signal, + }); - ...async () => { - const res = await fetch(`https://api.nostr.band/v0/stats/profile/${pubkey}`); if (!res.ok) { throw new Error('Error'); } + return await res.json(); }, + refetchOnWindowFocus: false, + refetchOnMount: false, + refetchOnReconnect: false, + staleTime: Infinity, }); if (status === 'pending') { diff --git a/src/app/users/index.tsx b/src/app/users/index.tsx index d2c09b3c..bcad621b 100644 --- a/src/app/users/index.tsx +++ b/src/app/users/index.tsx @@ -70,7 +70,6 @@ export function UserScreen() { return (
-

diff --git a/src/shared/accounts/active.tsx b/src/shared/accounts/active.tsx index 85dd7dc7..fb12d845 100644 --- a/src/shared/accounts/active.tsx +++ b/src/shared/accounts/active.tsx @@ -25,7 +25,7 @@ export function ActiveAccount() { return (
- + {db.account.pubkeypubkey} - +
); } diff --git a/src/shared/accounts/more.tsx b/src/shared/accounts/more.tsx index bbc4f82a..206d9851 100644 --- a/src/shared/accounts/more.tsx +++ b/src/shared/accounts/more.tsx @@ -1,15 +1,14 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu'; -import { useState } from 'react'; import { Link } from 'react-router-dom'; +import { useStorage } from '@libs/storage/provider'; + import { HorizontalDotsIcon } from '@shared/icons'; import { Logout } from '@shared/logout'; -export function AccountMoreActions({ pubkey }: { pubkey: string }) { - const [open, setOpen] = useState(false); - +export function AccountMoreActions() { return ( - +