chore: update state initial loader

This commit is contained in:
Steven
2023-09-15 08:31:19 +08:00
parent f5802a7d82
commit 936fe5ac9d
7 changed files with 58 additions and 66 deletions

View File

@ -5,7 +5,8 @@ import { Outlet } from "react-router-dom";
import storage from "./helpers/storage";
import { getSystemColorScheme } from "./helpers/utils";
import Loading from "./pages/Loading";
import { initialGlobalState, initialUserState, useGlobalStore } from "./store/module";
import store from "./store";
import { useGlobalStore } from "./store/module";
import { useUserV1Store } from "./store/v1";
const App = () => {
@ -18,21 +19,10 @@ const App = () => {
useEffect(() => {
const initialState = async () => {
try {
await initialGlobalState();
} catch (error) {
// do nothing
const { user } = store.getState().user;
if (user) {
await userV1Store.getOrFetchUserByUsername(user.username);
}
try {
const user = await initialUserState();
if (user) {
await userV1Store.getOrFetchUserByUsername(user.username);
}
} catch (error) {
// do nothing.
}
setLoading(false);
};