|
8 | 8 | rememberWhatsAppBaileysCacheEntry, |
9 | 9 | type WhatsAppBaileysGroupMetadataCache, |
10 | 10 | } from "./baileys-cache.js"; |
11 | | -import { attachEmitterListener } from "./lifecycle.js"; |
12 | 11 | import { |
13 | 12 | addWhatsAppOutboundMentionsToContent, |
14 | 13 | mayContainWhatsAppOutboundMention, |
@@ -38,6 +37,7 @@ type GroupMetadataCacheOwnerParams = { |
38 | 37 | resolveInboundJid: (jid: string | null | undefined) => Promise<string | null>; |
39 | 38 | reconnectCache?: WhatsAppGroupMetadataCache; |
40 | 39 | baileysCache?: WhatsAppBaileysGroupMetadataCache; |
| 40 | + listen: (event: string, listener: (...args: unknown[]) => void) => () => void; |
41 | 41 | logVerbose: (message: string) => void; |
42 | 42 | logHydrationWarning: (error: string) => void; |
43 | 43 | }; |
@@ -219,13 +219,8 @@ export function createWhatsAppGroupMetadataCacheOwner(params: GroupMetadataCache |
219 | 219 | return; |
220 | 220 | } |
221 | 221 | started = true; |
222 | | - const emitter = params.sock.ev as unknown as { |
223 | | - on: (event: string, listener: (...args: unknown[]) => void) => void; |
224 | | - off?: (event: string, listener: (...args: unknown[]) => void) => void; |
225 | | - removeListener?: (event: string, listener: (...args: unknown[]) => void) => void; |
226 | | - }; |
227 | 222 | const listen = (event: string, listener: (...args: unknown[]) => void) => { |
228 | | - detachListeners.push(attachEmitterListener(emitter, event, listener)); |
| 223 | + detachListeners.push(params.listen(event, listener)); |
229 | 224 | }; |
230 | 225 |
|
231 | 226 | listen("groups.upsert", ((groups: GroupMetadata[]) => { |
|
0 commit comments