lint fix wip
This commit is contained in:
parent
e97d2b32cc
commit
91fe30a860
@ -291,11 +291,15 @@ export function RelayManager({ onConfigChange }: RelayManagerProps): React.React
|
||||
handleDrop(e, relay.id)
|
||||
}}
|
||||
className={`bg-cyber-dark border rounded p-4 space-y-3 transition-all ${
|
||||
draggedId === relay.id
|
||||
? 'opacity-50 border-neon-cyan'
|
||||
: dragOverId === relay.id
|
||||
? 'border-neon-green shadow-lg'
|
||||
: 'border-neon-cyan/30'
|
||||
(() => {
|
||||
if (draggedId === relay.id) {
|
||||
return 'opacity-50 border-neon-cyan'
|
||||
}
|
||||
if (dragOverId === relay.id) {
|
||||
return 'border-neon-green shadow-lg'
|
||||
}
|
||||
return 'border-neon-cyan/30'
|
||||
})()
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
|
||||
@ -41,7 +41,12 @@ export function ReviewForm({ article, onSuccess, onCancel }: ReviewFormProps): R
|
||||
return
|
||||
}
|
||||
|
||||
const category = article.category === 'author-presentation' ? 'science-fiction' : (article.category ?? 'science-fiction')
|
||||
const category = (() => {
|
||||
if (article.category === 'author-presentation') {
|
||||
return 'science-fiction'
|
||||
}
|
||||
return article.category ?? 'science-fiction'
|
||||
})()
|
||||
const seriesId = article.seriesId ?? ''
|
||||
|
||||
await publishReview({
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
import type { Event } from 'nostr-tools'
|
||||
import type { SimplePoolWithSub } from '@/types/nostr-tools-extended'
|
||||
import { nostrService } from './nostr'
|
||||
import { getPrimaryRelaySync } from './config'
|
||||
import { PLATFORM_SERVICE, MIN_EVENT_DATE } from './platformConfig'
|
||||
import { buildTagFilter, extractTagsFromEvent } from './nostrTagSystem'
|
||||
import { objectCache } from './objectCache'
|
||||
@ -24,6 +23,7 @@ class PlatformSyncService {
|
||||
/**
|
||||
* Start background sync
|
||||
* Scans all notes with service='zapwall.fr' and caches them
|
||||
* Does not require pubkey - syncs all public notes with service='zapwall.fr'
|
||||
*/
|
||||
async startSync(): Promise<void> {
|
||||
if (this.syncInProgress) {
|
||||
@ -38,12 +38,25 @@ class PlatformSyncService {
|
||||
|
||||
this.syncInProgress = true
|
||||
|
||||
// Update progress manager to show sync indicator
|
||||
const { syncProgressManager } = await import('./syncProgressManager')
|
||||
const { relaySessionManager } = await import('./relaySessionManager')
|
||||
const activeRelays = await relaySessionManager.getActiveRelays()
|
||||
const initialRelay = activeRelays[0] ?? 'Connecting...'
|
||||
syncProgressManager.setProgress({ currentStep: 0, totalSteps: 1, completed: false, currentRelay: initialRelay })
|
||||
|
||||
try {
|
||||
await this.performSync(pool as unknown as SimplePoolWithSub)
|
||||
syncProgressManager.setProgress({ currentStep: 1, totalSteps: 1, completed: true, currentRelay: initialRelay })
|
||||
} catch (error) {
|
||||
console.error('Error in platform sync:', error)
|
||||
syncProgressManager.setProgress(null)
|
||||
} finally {
|
||||
this.syncInProgress = false
|
||||
// Clear progress after a short delay
|
||||
setTimeout(() => {
|
||||
syncProgressManager.setProgress(null)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,52 +75,71 @@ class PlatformSyncService {
|
||||
},
|
||||
]
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const relayUrl = getPrimaryRelaySync()
|
||||
const { createSubscription } = require('@/types/nostr-tools-extended')
|
||||
const sub = createSubscription(pool, [relayUrl], filters)
|
||||
// Use relay rotation for platform sync
|
||||
const { tryWithRelayRotation } = await import('./relayRotation')
|
||||
const { syncProgressManager } = await import('./syncProgressManager')
|
||||
|
||||
const events: Event[] = []
|
||||
let resolved = false
|
||||
|
||||
const finalize = async (): Promise<void> => {
|
||||
if (resolved) {
|
||||
return
|
||||
return tryWithRelayRotation(
|
||||
pool as unknown as import('nostr-tools').SimplePool,
|
||||
async (relayUrl, poolWithSub) => {
|
||||
// Update progress with current relay
|
||||
const currentProgress = syncProgressManager.getProgress()
|
||||
if (currentProgress) {
|
||||
syncProgressManager.setProgress({
|
||||
...currentProgress,
|
||||
currentRelay: relayUrl,
|
||||
})
|
||||
}
|
||||
resolved = true
|
||||
sub.unsub()
|
||||
this.syncSubscription = null
|
||||
|
||||
// Process all events and cache them
|
||||
await this.processAndCacheEvents(events)
|
||||
const { createSubscription } = require('@/types/nostr-tools-extended')
|
||||
const sub = createSubscription(poolWithSub, [relayUrl], filters)
|
||||
|
||||
this.lastSyncTime = Date.now()
|
||||
resolve()
|
||||
}
|
||||
const events: Event[] = []
|
||||
let resolved = false
|
||||
|
||||
sub.on('event', (event: Event): void => {
|
||||
// Only process events with service='zapwall.fr'
|
||||
const tags = extractTagsFromEvent(event)
|
||||
if (tags.service === PLATFORM_SERVICE) {
|
||||
events.push(event)
|
||||
const finalize = async (): Promise<void> => {
|
||||
if (resolved) {
|
||||
return
|
||||
}
|
||||
resolved = true
|
||||
sub.unsub()
|
||||
this.syncSubscription = null
|
||||
|
||||
// Process all events and cache them
|
||||
await this.processAndCacheEvents(events)
|
||||
|
||||
this.lastSyncTime = Date.now()
|
||||
}
|
||||
})
|
||||
|
||||
sub.on('eose', (): void => {
|
||||
void (async (): Promise<void> => {
|
||||
await finalize()
|
||||
})()
|
||||
})
|
||||
return new Promise<void>((resolve) => {
|
||||
sub.on('event', (event: Event): void => {
|
||||
// Only process events with service='zapwall.fr'
|
||||
const tags = extractTagsFromEvent(event)
|
||||
if (tags.service === PLATFORM_SERVICE) {
|
||||
events.push(event)
|
||||
}
|
||||
})
|
||||
|
||||
// Timeout after SYNC_TIMEOUT_MS
|
||||
setTimeout((): void => {
|
||||
void (async (): Promise<void> => {
|
||||
await finalize()
|
||||
})()
|
||||
}, this.SYNC_TIMEOUT_MS).unref?.()
|
||||
sub.on('eose', (): void => {
|
||||
void (async (): Promise<void> => {
|
||||
await finalize()
|
||||
resolve()
|
||||
})()
|
||||
})
|
||||
|
||||
this.syncSubscription = sub
|
||||
})
|
||||
// Timeout after SYNC_TIMEOUT_MS
|
||||
setTimeout((): void => {
|
||||
void (async (): Promise<void> => {
|
||||
await finalize()
|
||||
resolve()
|
||||
})()
|
||||
}, this.SYNC_TIMEOUT_MS).unref?.()
|
||||
|
||||
this.syncSubscription = sub
|
||||
})
|
||||
},
|
||||
30000 // 30 second timeout per relay
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user