From 9fc96d0afce69db3c2aad32c5270b30ed8ce2662 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Mon, 17 May 2021 15:35:12 +0200 Subject: [PATCH] only query each client session once (#601) this makes the ids unique so that they only get queried once --- src/App.tsx | 2 +- src/sessions/SessionsSection.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ed41e07447..a4a7f553e1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -69,7 +69,7 @@ export const App = () => { > window.location.reload()} > {routes(() => {}).map((route, i) => ( diff --git a/src/sessions/SessionsSection.tsx b/src/sessions/SessionsSection.tsx index b66ba25e88..749dabc54e 100644 --- a/src/sessions/SessionsSection.tsx +++ b/src/sessions/SessionsSection.tsx @@ -33,11 +33,12 @@ export const SessionsSection = () => { ) ).flat(); + const userIds = Array.from( + new Set(clientSessions.map((session) => session.userId)) + ); const userSessions = ( await Promise.all( - clientSessions.map((session) => - adminClient.users.listSessions({ id: session.userId! }) - ) + userIds.map((userId) => adminClient.users.listSessions({ id: userId! })) ) ).flat();