diff --git a/src/layouts/Main.tsx b/src/layouts/Main.tsx index f3962eb..9402e97 100644 --- a/src/layouts/Main.tsx +++ b/src/layouts/Main.tsx @@ -109,6 +109,7 @@ export const MainLayout = () => { if (pubkey && !hasSubscribed.current) { // Call `subscribeForSigits` only if it hasn't been called before + // #193 disabled websocket subscribtion, until #194 is done subscribeForSigits(pubkey) // Mark `subscribeForSigits` as called diff --git a/src/utils/nostr.ts b/src/utils/nostr.ts index eceb8d8..0a3e052 100644 --- a/src/utils/nostr.ts +++ b/src/utils/nostr.ts @@ -859,9 +859,16 @@ export const subscribeForSigits = async (pubkey: string) => { '#p': [pubkey] } - relayController.subscribeForEvents(filter, relaySet.read, (event) => { - processReceivedEvent(event) // Process the received event - }) + // Process the received event synchronously + const events = await relayController.fetchEvents(filter, relaySet.read) + for (const e of events) { + await processReceivedEvent(e) + } + + // Async processing of the events has a race condition + // relayController.subscribeForEvents(filter, relaySet.read, (event) => { + // processReceivedEvent(event) + // }) } const processReceivedEvent = async (event: Event, difficulty: number = 5) => { @@ -907,7 +914,7 @@ const processReceivedEvent = async (event: Event, difficulty: number = 5) => { if (!meta) return - updateUsersAppData(meta) + await updateUsersAppData(meta) } /**