more logging

This commit is contained in:
Daniel Lugo 2020-02-27 13:28:05 -04:00
parent 28a473740c
commit a214a4cd56
2 changed files with 16 additions and 1 deletions

View file

@ -326,6 +326,10 @@ const getCurrentOutgoings = () => currentOutgoings
/** @type {Set<OutgoingsListener>} */
const outgoingsListeners = new Set()
outgoingsListeners.add(o => {
logger.info(`new outgoings: ${JSON.stringify(o, null, 4)}`)
})
const notifyOutgoingsListeners = () => {
outgoingsListeners.forEach(l => l(currentOutgoings))
}
@ -442,6 +446,10 @@ const getChats = () => currentChats
/** @type {Set<ChatsListener>} */
const chatsListeners = new Set()
chatsListeners.add(c => {
logger.info(`new Chats: ${JSON.stringify(c, null, 4)}`)
})
const notifyChatsListeners = () => {
chatsListeners.forEach(l => l(currentChats))
}
@ -540,7 +548,7 @@ let currentBio = null
* @param {(bio: string|null) => void} cb
* @param {UserGUNNode} user Pass only for testing purposes.
* @throws {Error} If user hasn't been auth.
* @returns {void}
* @returns {void}outgoingsListeners.forEach()
*/
const onBio = (cb, user) => {
if (!user.is) {

View file

@ -1,6 +1,7 @@
/** @format */
const uuidv1 = require('uuid/v1')
const debounce = require('lodash/debounce')
const logger = require('winston')
const { USER_TO_INCOMING } = require('../key')
const { asyncForEach } = require('../utils')
@ -28,6 +29,12 @@ const setPubToIncoming = pti => {
let latestUpdate = uuidv1()
listeners.add(() => {
logger.info(
`new pubToIncoming: ${JSON.stringify(getPubToIncoming(), null, 4)}`
)
})
const onOpen = debounce(async uti => {
const SEA = require('../../Mediator').mySEA
const mySec = require('../../Mediator').getMySecret()