Skip to content

Conversation

@Maphikza
Copy link
Member

@Maphikza Maphikza commented Jul 4, 2025

Summary

This PR implements hybrid profile fetching with NIP-42 authentication and includes bug fixes and performance improvements:

  • Implement NIP-42 authentication: Add proper Nostr relay authentication with NDK
  • Hybrid profile fetching: Combine NDK profile data with backend API fallback
  • Fix paid subscribers logic: Stop using dummy data when real subscribers are available
  • Improve Bitcoin rates caching: Add 8-minute cache with request deduplication
  • Clean up console output: Remove excessive debug logs across components

Changes

🔐 Authentication & Profile Fetching

  • Add environment-based NDK configuration with relay URLs
  • Implement NIP-42 authentication using NDKRelayAuthPolicies.signIn
  • Create hybrid profile fetching strategy: NDK first, backend API fallback
  • Fix authentication issues in LoginForm and useWalletAuth
  • Improve display name parsing from Nostr profile data
  • Prevent infinite loops with better profile caching logic
  • Remove global Window.nostr declaration to avoid NDK conflicts

🐛 Bug Fixes

  • Only use dummy subscriber data when no real subscribers exist
  • Keep existing real subscribers during API errors instead of falling back to dummy data
  • Initialize subscriber state with empty array instead of dummy profiles

⚡ Performance

  • Add global caching for Bitcoin rates API (8-minute cache duration)
  • Implement request deduplication to prevent multiple simultaneous API calls
  • Reduce unnecessary API requests when multiple components use useBitcoinRates

🧹 Code Cleanup

  • Remove excessive console.log statements from dashboard components
  • Fix unused variables after log removal

Files Changed

  • .env.development - Add NDK relay configuration
  • src/App.tsx - NDK setup and initialization
  • src/components/auth/LoginForm/LoginForm.tsx - Auth improvements
  • src/components/relay-dashboard/paid-subscribers/PaidSubscribers.tsx - Hybrid profile fetching
  • src/hooks/usePaidSubscribers.ts - Subscriber logic fixes
  • src/hooks/useBitcoinRates.ts - Caching improvements
  • src/hooks/useWalletAuth.ts - Authentication fixes
  • src/config/config.ts - NDK configuration
  • src/types/nostr.ts - Type definitions
  • src/utils/utils.ts - Profile parsing utilities
  • Multiple component files - Console cleanup

AnthonyMarin and others added 26 commits July 2, 2025 14:55
- Add environment-based NDK configuration with relay URLs
- Implement NIP-42 authentication using NDKRelayAuthPolicies.signIn
- Create hybrid profile fetching: NDK first, backend API fallback
- Fix authentication issues in LoginForm and useWalletAuth
- Improve display name parsing from Nostr profile data
- Prevent infinite loops with better profile caching logic
- Remove global Window.nostr declaration to avoid NDK conflicts
- Only use dummy data when no real subscribers exist
- Keep existing real subscribers during errors
- Initialize with empty array instead of dummy profiles
- Remove debug logs from TotalEarning.tsx
- Remove chart data logs from TotalEarningChart.tsx
- Remove API response logs from activity.api.ts
- Remove extensive debug logs from useChartData.ts
- Remove component logs from PaidSubscribers.tsx
- Fix unused variables after log removal
@f7f376a1fcd0d0e11a10ed1b6577c9 f7f376a1fcd0d0e11a10ed1b6577c9 merged commit 1685b8c into main Jul 4, 2025
2 checks passed
@Maphikza Maphikza deleted the feature/ndk-integration-fix-cleanup branch July 5, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants