mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2025-08-27 04:59:22 +00:00
context updae + app nwccontext
This commit is contained in:
parent
8183e3cc5a
commit
9ed8676d17
14
CONTEXT.md
14
CONTEXT.md
@ -18,6 +18,7 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3.
|
|||||||
- `/src/components/`: UI components including NostrProvider for Nostr integration
|
- `/src/components/`: UI components including NostrProvider for Nostr integration
|
||||||
- `/src/components/ui/`: shadcn/ui components (48+ components available)
|
- `/src/components/ui/`: shadcn/ui components (48+ components available)
|
||||||
- `/src/components/auth/`: Authentication-related components (LoginArea, LoginDialog, etc.)
|
- `/src/components/auth/`: Authentication-related components (LoginArea, LoginDialog, etc.)
|
||||||
|
- Zap components: `ZapButton`, `ZapDialog`, `WalletModal` for Lightning payments
|
||||||
- `/src/hooks/`: Custom hooks including:
|
- `/src/hooks/`: Custom hooks including:
|
||||||
- `useNostr`: Core Nostr protocol integration
|
- `useNostr`: Core Nostr protocol integration
|
||||||
- `useAuthor`: Fetch user profile data by pubkey
|
- `useAuthor`: Fetch user profile data by pubkey
|
||||||
@ -31,9 +32,13 @@ This project is a Nostr client application built with React 18.x, TailwindCSS 3.
|
|||||||
- `useLoggedInAccounts`: Manage multiple accounts
|
- `useLoggedInAccounts`: Manage multiple accounts
|
||||||
- `useLoginActions`: Authentication actions
|
- `useLoginActions`: Authentication actions
|
||||||
- `useIsMobile`: Responsive design helper
|
- `useIsMobile`: Responsive design helper
|
||||||
|
- `useZaps`: Lightning zap functionality with payment processing
|
||||||
|
- `useWallet`: Unified wallet detection (WebLN + NWC)
|
||||||
|
- `useNWC`: Nostr Wallet Connect connection management
|
||||||
|
- `useNWCContext`: Access NWC context provider
|
||||||
- `/src/pages/`: Page components used by React Router (Index, NotFound)
|
- `/src/pages/`: Page components used by React Router (Index, NotFound)
|
||||||
- `/src/lib/`: Utility functions and shared logic
|
- `/src/lib/`: Utility functions and shared logic
|
||||||
- `/src/contexts/`: React context providers (AppContext)
|
- `/src/contexts/`: React context providers (AppContext, NWCContext)
|
||||||
- `/src/test/`: Testing utilities including TestApp component
|
- `/src/test/`: Testing utilities including TestApp component
|
||||||
- `/public/`: Static assets
|
- `/public/`: Static assets
|
||||||
- `App.tsx`: Main app component with provider setup
|
- `App.tsx`: Main app component with provider setup
|
||||||
@ -669,10 +674,15 @@ import { NWCProvider } from '@/contexts/NWCContext';
|
|||||||
```
|
```
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
// Use unified wallet detection
|
// Use unified wallet detection and zap components
|
||||||
const { webln, activeNWC, preferredMethod } = useWallet();
|
const { webln, activeNWC, preferredMethod } = useWallet();
|
||||||
const { zap } = useZaps(target, webln, activeNWC, onSuccess);
|
const { zap } = useZaps(target, webln, activeNWC, onSuccess);
|
||||||
|
|
||||||
|
// Pre-built components available
|
||||||
|
import { ZapButton } from '@/components/ZapButton';
|
||||||
|
import { ZapDialog } from '@/components/ZapDialog';
|
||||||
|
import { WalletModal } from '@/components/WalletModal';
|
||||||
|
|
||||||
// Validate recipient can receive zaps
|
// Validate recipient can receive zaps
|
||||||
if (!author.metadata?.lud16 && !author.metadata?.lud06) {
|
if (!author.metadata?.lud16 && !author.metadata?.lud06) {
|
||||||
return null; // Hide zap button
|
return null; // Hide zap button
|
||||||
|
17
src/App.tsx
17
src/App.tsx
@ -11,6 +11,7 @@ import { Toaster as Sonner } from "@/components/ui/sonner";
|
|||||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||||
import { NostrLoginProvider } from '@nostrify/react/login';
|
import { NostrLoginProvider } from '@nostrify/react/login';
|
||||||
import { AppProvider } from '@/components/AppProvider';
|
import { AppProvider } from '@/components/AppProvider';
|
||||||
|
import { NWCProvider } from '@/contexts/NWCContext';
|
||||||
import { AppConfig } from '@/contexts/AppContext';
|
import { AppConfig } from '@/contexts/AppContext';
|
||||||
import AppRouter from './AppRouter';
|
import AppRouter from './AppRouter';
|
||||||
|
|
||||||
@ -49,13 +50,15 @@ export function App() {
|
|||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<NostrLoginProvider storageKey='nostr:login'>
|
<NostrLoginProvider storageKey='nostr:login'>
|
||||||
<NostrProvider>
|
<NostrProvider>
|
||||||
<TooltipProvider>
|
<NWCProvider>
|
||||||
<Toaster />
|
<TooltipProvider>
|
||||||
<Sonner />
|
<Toaster />
|
||||||
<Suspense>
|
<Sonner />
|
||||||
<AppRouter />
|
<Suspense>
|
||||||
</Suspense>
|
<AppRouter />
|
||||||
</TooltipProvider>
|
</Suspense>
|
||||||
|
</TooltipProvider>
|
||||||
|
</NWCProvider>
|
||||||
</NostrProvider>
|
</NostrProvider>
|
||||||
</NostrLoginProvider>
|
</NostrLoginProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
@ -4,6 +4,7 @@ import { BrowserRouter } from 'react-router-dom';
|
|||||||
import { NostrLoginProvider } from '@nostrify/react/login';
|
import { NostrLoginProvider } from '@nostrify/react/login';
|
||||||
import NostrProvider from '@/components/NostrProvider';
|
import NostrProvider from '@/components/NostrProvider';
|
||||||
import { AppProvider } from '@/components/AppProvider';
|
import { AppProvider } from '@/components/AppProvider';
|
||||||
|
import { NWCProvider } from '@/contexts/NWCContext';
|
||||||
import { AppConfig } from '@/contexts/AppContext';
|
import { AppConfig } from '@/contexts/AppContext';
|
||||||
|
|
||||||
interface TestAppProps {
|
interface TestAppProps {
|
||||||
@ -31,9 +32,11 @@ export function TestApp({ children }: TestAppProps) {
|
|||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<NostrLoginProvider storageKey='test-login'>
|
<NostrLoginProvider storageKey='test-login'>
|
||||||
<NostrProvider>
|
<NostrProvider>
|
||||||
<BrowserRouter>
|
<NWCProvider>
|
||||||
{children}
|
<BrowserRouter>
|
||||||
</BrowserRouter>
|
{children}
|
||||||
|
</BrowserRouter>
|
||||||
|
</NWCProvider>
|
||||||
</NostrProvider>
|
</NostrProvider>
|
||||||
</NostrLoginProvider>
|
</NostrLoginProvider>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user