From 2303409ecbb3b13141ca311367610fddadb6bd6c Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 24 Oct 2023 12:35:59 +0100 Subject: [PATCH] hopefully make the page load faster --- src/components/AppProvider.tsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/components/AppProvider.tsx b/src/components/AppProvider.tsx index f6412eb..d6553dd 100644 --- a/src/components/AppProvider.tsx +++ b/src/components/AppProvider.tsx @@ -21,19 +21,23 @@ export default class AppProvider extends React.Component { } this._state.mounted = true; - // Load data from async storage - await useSettingsStore.persist.rehydrate(); - await useScoresaberScoresStore.persist.rehydrate(); + const initUpdater = async () => { + // Load data from async storage + await useSettingsStore.persist.rehydrate(); + await useScoresaberScoresStore.persist.rehydrate(); - await useSettingsStore.getState().refreshProfiles(); - setInterval(() => { - useSettingsStore.getState().refreshProfiles(); - }, UPDATE_INTERVAL); + await useSettingsStore.getState().refreshProfiles(); + setInterval(() => { + useSettingsStore.getState().refreshProfiles(); + }, UPDATE_INTERVAL); - await useScoresaberScoresStore.getState().updatePlayerScores(); - setInterval(() => { - useScoresaberScoresStore.getState().updatePlayerScores(); - }, UPDATE_INTERVAL); + await useScoresaberScoresStore.getState().updatePlayerScores(); + setInterval(() => { + useScoresaberScoresStore.getState().updatePlayerScores(); + }, UPDATE_INTERVAL); + }; + + initUpdater(); } constructor(props: any) {