avoid stack overflow

This commit is contained in:
Daniel Lugo 2020-01-29 14:43:55 -04:00
parent 0713d5500b
commit f6dd79c159
2 changed files with 14 additions and 6 deletions

View file

@ -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)

View file

@ -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 () => {