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:
parent
0324cf8ec5
commit
236a8a59b9
5 changed files with 85 additions and 38 deletions
|
|
@ -18,8 +18,7 @@ const notes = ref<NostrNote[]>([])
|
|||
const isLoading = ref(true)
|
||||
const error = ref<Error | null>(null)
|
||||
|
||||
const relayUrls = props.relays || config.nostr.relays
|
||||
const { disconnect } = useNostr({ relays: relayUrls })
|
||||
const { getClient } = useNostr(props.relays ? { relays: props.relays } : undefined)
|
||||
|
||||
// Get admin/moderator pubkeys from centralized config
|
||||
const adminPubkeys = config.nostr.adminPubkeys
|
||||
|
|
@ -29,7 +28,7 @@ async function loadNotes() {
|
|||
isLoading.value = true
|
||||
error.value = null
|
||||
|
||||
const client = new NostrClient({ relays: relayUrls })
|
||||
const client = getClient()
|
||||
await client.connect()
|
||||
|
||||
// Configure fetch options based on feed type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue