From 31b11aefd65fcfc8844b818cb41eefd95eef7b33 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Wed, 8 Nov 2023 15:34:48 +1300 Subject: [PATCH] Prevent lag on insights page - Queries were being run in parallel, now they run sequentially - Add 400ms delay before starting the queries, to allow for drawer navigation animation. --- InsightsPage.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/InsightsPage.tsx b/InsightsPage.tsx index eb24474..1f44319 100644 --- a/InsightsPage.tsx +++ b/InsightsPage.tsx @@ -51,8 +51,17 @@ export default function InsightsPage() { having hour is not null ORDER BY hour `; - AppDataSource.manager.query(selectWeeks).then(setWeekCounts); - AppDataSource.manager.query(selectHours).then(setHourCounts); + + setTimeout( + () => + AppDataSource.manager + .query(selectWeeks) + .then(setWeekCounts) + .then(() => + AppDataSource.manager.query(selectHours).then(setHourCounts) + ), + 400 + ); }, [period]) );