From 59a238b3c79b10422ee78e8bbf0c8024a70a7660 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 30 Jan 2020 07:48:13 -0400 Subject: [PATCH] use getters --- services/gunDB/contact-api/events/index.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/services/gunDB/contact-api/events/index.js b/services/gunDB/contact-api/events/index.js index cec931f4..1330f0af 100644 --- a/services/gunDB/contact-api/events/index.js +++ b/services/gunDB/contact-api/events/index.js @@ -432,12 +432,6 @@ const onOutgoing = cb => { /** @type {Outgoings} */ let outgoings = {} -/** @type {Streams.Avatars} */ -let pubToAvatar = {} - -/** @type {Streams.DisplayNames} */ -let pubToDn = {} - /** * @typedef {(chats: Chat[]) => void} ChatsListener */ @@ -453,6 +447,8 @@ const notifyChatsListeners = () => { } const processChats = () => { + const pubToAvatar = Streams.getPubToAvatar() + const pubToDn = Streams.getPubToDn() const existingOutgoings = /** @type {[string, Outgoing][]} */ (Object.entries( outgoings ).filter(([_, o]) => o !== null)) @@ -521,14 +517,8 @@ const onChats = cb => { processChats() }) - Streams.onAvatar(pta => { - pubToAvatar = pta - processChats() - }) - Streams.onDisplayName(ptd => { - pubToDn = ptd - processChats() - }) + Streams.onAvatar(processChats) + Streams.onDisplayName(processChats) Streams.onIncoming(processChats) return () => {