diff --git a/services/gunDB/contact-api/events.js b/services/gunDB/contact-api/events.js index 37fc10bb..4429e34b 100644 --- a/services/gunDB/contact-api/events.js +++ b/services/gunDB/contact-api/events.js @@ -491,10 +491,14 @@ const processChats = () => { chats.push(chat) - // eslint-disable-next-line no-empty-function - Streams.onAvatar(() => {}, out.with) - // eslint-disable-next-line no-empty-function - Streams.onDisplayName(() => {}, out.with) + if (typeof pubToAvatar[out.with] === 'undefined') { + // eslint-disable-next-line no-empty-function + Streams.onAvatar(() => {}, out.with) + } + if (typeof pubToDn[out.with] === 'undefined') { + // eslint-disable-next-line no-empty-function + Streams.onDisplayName(() => {}, out.with) + } } currentChats = chats.filter(c => c.messages.length > 0) diff --git a/services/gunDB/contact-api/streams.js b/services/gunDB/contact-api/streams.js index 00e7e206..de370a26 100644 --- a/services/gunDB/contact-api/streams.js +++ b/services/gunDB/contact-api/streams.js @@ -37,8 +37,10 @@ const onAvatar = (cb, pub) => { .on(av => { if (typeof av === 'string' || av === null) { pubToAvatar[pub] = av || null - notifyAvatarListeners() + } else { + pubToAvatar[pub] = null } + notifyAvatarListeners() }) } return () => { @@ -80,8 +82,10 @@ const onDisplayName = (cb, pub) => { .on(dn => { if (typeof dn === 'string' || dn === null) { pubToDisplayName[pub] = dn || null - notifyDisplayNameListeners() + } else { + pubToDisplayName } + notifyDisplayNameListeners() }) } return () => {