refactor: Simplify Nostr connection management and enhance store integration

- Refactor useNostr composable to utilize a centralized Pinia store for connection state and client management.
- Update NostrFeed and App components to leverage the new store-based approach for relay configuration and client instantiation.
- Remove direct relay URL handling from components, improving maintainability and consistency across the application.
This commit is contained in:
padreug 2025-07-02 19:49:06 +02:00
parent 0324cf8ec5
commit 236a8a59b9
5 changed files with 85 additions and 38 deletions

View file

@ -4,8 +4,11 @@ import { createTextNote, createReaction, createProfileMetadata } from '@/lib/nos
import { identity } from '@/composables/useIdentity'
import { toast } from 'vue-sonner'
export function useSocial(relayUrls: string[]) {
const client = new NostrClient({ relays: relayUrls })
import { useNostr } from './useNostr'
export function useSocial(relayUrls?: string[]) {
const { getClient } = useNostr(relayUrls ? { relays: relayUrls } : undefined)
const client = getClient()
const isPublishing = ref(false)
const profiles = ref(new Map<string, any>())
@ -152,5 +155,4 @@ export function useSocial(relayUrls: string[]) {
}
// Export singleton instance for global use
import { config } from '@/lib/config'
export const social = useSocial(config.nostr.relays)
export const social = useSocial()