From 09a2b6b622fc64a4b73cefece225a202b8cb77a3 Mon Sep 17 00:00:00 2001 From: aman035 Date: Wed, 14 Feb 2024 13:58:38 +0530 Subject: [PATCH] fix: optimize chat.list --- .../restapi/src/lib/chat/helpers/inbox.ts | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/packages/restapi/src/lib/chat/helpers/inbox.ts b/packages/restapi/src/lib/chat/helpers/inbox.ts index c2e0314cd..6a3412600 100644 --- a/packages/restapi/src/lib/chat/helpers/inbox.ts +++ b/packages/restapi/src/lib/chat/helpers/inbox.ts @@ -41,44 +41,18 @@ export const getInboxLists = async ( pgpHelper = PGP.PGPHelper ): Promise => { const { - lists, + lists: feeds, user, toDecrypt, pgpPrivateKey, env = Constants.ENV.PROD, } = options || {}; - const connectedUser = await getUser({ account: pCAIP10ToWallet(user), env }); - const feeds: IFeeds[] = []; - for (const list of lists) { - let message; - if (list.threadhash !== null) { - message = await getCID(list.threadhash, { env }); - } - // This is for groups that are created without any message - else { - message = { - encType: 'PlainText', - encryptedSecret: '', - fromCAIP10: '', - fromDID: '', - link: '', - messageContent: '', - messageType: '', - sigType: '', - signature: '', - toCAIP10: '', - toDID: '', - }; - } - feeds.push({ - ...list, - msg: message, - groupInformation: list.groupInformation, + if (toDecrypt) { + const connectedUser = await getUser({ + account: pCAIP10ToWallet(user), + env, }); - } - - if (toDecrypt) return decryptFeeds({ feeds, connectedUser, @@ -86,6 +60,7 @@ export const getInboxLists = async ( pgpHelper, env, }); + } return feeds; };