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.
This commit is contained in:
Brandon Presley 2023-11-08 15:34:48 +13:00
parent 8a88c8e7af
commit 31b11aefd6
1 changed files with 11 additions and 2 deletions

View File

@ -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])
);