From f22e1160db29e341b865a85c0f522941648739ae Mon Sep 17 00:00:00 2001 From: kele-leanes Date: Mon, 18 Dec 2023 15:23:44 -0300 Subject: [PATCH] unsubscribe message event --- src/lib/Conversation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/Conversation.ts b/src/lib/Conversation.ts index 99ee38d4..5a2cfa0b 100644 --- a/src/lib/Conversation.ts +++ b/src/lib/Conversation.ts @@ -229,7 +229,7 @@ export class Conversation { ): () => void { XMTP.subscribeToMessages(this.client.address, this.topic) const hasSeen = {} - XMTP.emitter.addListener( + const messageSubscription = XMTP.emitter.addListener( 'message', async ({ clientAddress, @@ -253,6 +253,7 @@ export class Conversation { ) return () => { + messageSubscription.remove() XMTP.unsubscribeFromMessages(this.client.address, this.topic) } }