From 5902e6cc72c08746881463f363ef56475c4d810f Mon Sep 17 00:00:00 2001 From: shocknet-justin Date: Fri, 19 Dec 2025 02:02:58 -0500 Subject: [PATCH] onready --- src/services/main/liquidityProvider.ts | 10 ++++++++++ src/services/nostr/sender.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/services/main/liquidityProvider.ts b/src/services/main/liquidityProvider.ts index 3bf1f0cc..baeb812a 100644 --- a/src/services/main/liquidityProvider.ts +++ b/src/services/main/liquidityProvider.ts @@ -56,7 +56,17 @@ export class LiquidityProvider { retrieveNostrGuestWithPubAuth: async () => this.localPubkey }, this.clientSend, this.clientSub) + this.utils.nostrSender.OnReady(() => { + this.setSetIfConfigured() + if (this.configured) { + clearInterval(this.configuredInterval) + this.Connect() + } + }) this.configuredInterval = setInterval(() => { + if (!this.configured && this.utils.nostrSender.IsReady()) { + this.setSetIfConfigured() + } if (this.configured) { clearInterval(this.configuredInterval) this.Connect() diff --git a/src/services/nostr/sender.ts b/src/services/nostr/sender.ts index c3d0c2f2..c061dc56 100644 --- a/src/services/nostr/sender.ts +++ b/src/services/nostr/sender.ts @@ -2,9 +2,19 @@ import { NostrSend, SendData, SendInitiator } from "./nostrPool.js" export class NostrSender { private _nostrSend: NostrSend = () => { throw new Error('nostr send not initialized yet') } private isReady: boolean = false + private onReadyCallbacks: (() => void)[] = [] AttachNostrSend(nostrSend: NostrSend) { this._nostrSend = nostrSend 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) { if (!this._nostrSend) {