From 13b49e658dd1ea75873fbde463e68593749080c9 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sun, 12 Dec 2021 12:25:03 +0530 Subject: [PATCH] fix: do not fetch empty ID list on transaction --- src/Utils/auth-utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Utils/auth-utils.ts b/src/Utils/auth-utils.ts index 3ad7e1a..3a5dc5f 100644 --- a/src/Utils/auth-utils.ts +++ b/src/Utils/auth-utils.ts @@ -27,10 +27,13 @@ export const addTransactionCapability = (state: SignalKeyStore, logger: Logger): const dict = transactionCache[type] const idsRequiringFetch = ids.filter(item => !dict?.[item]) - const result = await state.get(type, idsRequiringFetch) + // only fetch if there are any items to fetch + if(idsRequiringFetch.length) { + const result = await state.get(type, idsRequiringFetch) - transactionCache[type] = transactionCache[type] || { } - Object.assign(transactionCache[type], result) + transactionCache[type] = transactionCache[type] || { } + Object.assign(transactionCache[type], result) + } } return {