This commit is contained in:
shocknet-justin 2025-12-19 02:02:58 -05:00
parent 412bf4716d
commit 5902e6cc72
2 changed files with 20 additions and 0 deletions

View file

@ -56,7 +56,17 @@ export class LiquidityProvider {
retrieveNostrGuestWithPubAuth: async () => this.localPubkey retrieveNostrGuestWithPubAuth: async () => this.localPubkey
}, this.clientSend, this.clientSub) }, this.clientSend, this.clientSub)
this.utils.nostrSender.OnReady(() => {
this.setSetIfConfigured()
if (this.configured) {
clearInterval(this.configuredInterval)
this.Connect()
}
})
this.configuredInterval = setInterval(() => { this.configuredInterval = setInterval(() => {
if (!this.configured && this.utils.nostrSender.IsReady()) {
this.setSetIfConfigured()
}
if (this.configured) { if (this.configured) {
clearInterval(this.configuredInterval) clearInterval(this.configuredInterval)
this.Connect() this.Connect()

View file

@ -2,9 +2,19 @@ import { NostrSend, SendData, SendInitiator } from "./nostrPool.js"
export class NostrSender { export class NostrSender {
private _nostrSend: NostrSend = () => { throw new Error('nostr send not initialized yet') } private _nostrSend: NostrSend = () => { throw new Error('nostr send not initialized yet') }
private isReady: boolean = false private isReady: boolean = false
private onReadyCallbacks: (() => void)[] = []
AttachNostrSend(nostrSend: NostrSend) { AttachNostrSend(nostrSend: NostrSend) {
this._nostrSend = nostrSend this._nostrSend = nostrSend
this.isReady = true this.isReady = true
this.onReadyCallbacks.forEach(cb => cb())
this.onReadyCallbacks = []
}
OnReady(callback: () => void) {
if (this.isReady) {
callback()
} else {
this.onReadyCallbacks.push(callback)
}
} }
Send(initiator: SendInitiator, data: SendData, relays?: string[] | undefined) { Send(initiator: SendInitiator, data: SendData, relays?: string[] | undefined) {
if (!this._nostrSend) { if (!this._nostrSend) {