Refactor NostrFeed.vue for improved connection handling
- Simplify connection checks by directly accessing the isConnected property of relayHub, enhancing code clarity. - Update the loadNotes and startRealtimeSubscription functions to reflect the new connection logic, improving maintainability.
This commit is contained in:
parent
6c1d040e60
commit
d33d2abf8a
1 changed files with 3 additions and 3 deletions
|
|
@ -72,11 +72,11 @@ async function loadNotes() {
|
||||||
error.value = null
|
error.value = null
|
||||||
|
|
||||||
// Connect to relay hub if not already connected
|
// Connect to relay hub if not already connected
|
||||||
if (!relayHub.isConnected.value) {
|
if (!relayHub.isConnected) {
|
||||||
await relayHub.connect()
|
await relayHub.connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
isConnected.value = relayHub.isConnected.value
|
isConnected.value = relayHub.isConnected
|
||||||
|
|
||||||
if (!isConnected.value) {
|
if (!isConnected.value) {
|
||||||
throw new Error('Failed to connect to Nostr relays')
|
throw new Error('Failed to connect to Nostr relays')
|
||||||
|
|
@ -138,7 +138,7 @@ async function refreshFeed() {
|
||||||
let unsubscribe: (() => void) | null = null
|
let unsubscribe: (() => void) | null = null
|
||||||
|
|
||||||
async function startRealtimeSubscription() {
|
async function startRealtimeSubscription() {
|
||||||
if (!relayHub.isConnected.value) return
|
if (!relayHub.isConnected) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filters: any[] = [{
|
const filters: any[] = [{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue