From 61ece2905a50b72a71e3bc7e33a9e20e560356b2 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Tue, 28 Jan 2020 21:00:47 -0400 Subject: [PATCH] disconnect deletes last req sent id --- services/gunDB/contact-api/utils/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index 4d523907..c67eee1a 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -116,8 +116,9 @@ const reqToRecipientPub = async (reqID, SEA, mySecret) => { /** * Should only be called with a recipient pub that has already been contacted. + * If returns null, a disconnect happened. * @param {string} recipientPub - * @returns {Promise} + * @returns {Promise} */ const recipientPubToLastReqSentID = async recipientPub => { const lastReqSentID = await tryAndWait(async (_, user) => { @@ -125,7 +126,7 @@ const recipientPubToLastReqSentID = async recipientPub => { const data = await userToLastReqSent.get(recipientPub).then() if (typeof data !== 'string') { - throw new TypeError("typeof latestReqSentID !== 'string'") + return null } return data