chore: update router loader (#1102)

pull/1104/head
boojack 2 years ago committed by GitHub
parent 4f5f541efe
commit d29c40dc71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -157,10 +157,6 @@ const SystemSection = () => {
<span className="normal-text">{t("setting.system-section.disable-public-memos")}</span>
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
</div>
<div className="form-label">
<span className="normal-text">Storage</span>
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
</div>
<Divider className="!mt-3 !my-4" />
<div className="form-label">
<span className="normal-text">{t("setting.system-section.additional-style")}</span>

@ -52,7 +52,7 @@ i18n.use(initReactI18next).init({
translation: hantLocale,
},
},
lng: "nl",
lng: "en",
fallbackLng: "en",
});

@ -11,16 +11,28 @@ const MemoDetail = lazy(() => import("../pages/MemoDetail"));
const EmbedMemo = lazy(() => import("../pages/EmbedMemo"));
const NotFound = lazy(() => import("../pages/NotFound"));
const initialGlobalStateLoader = (() => {
let done = false;
return async () => {
if (done) {
return;
}
done = true;
try {
await initialGlobalState();
} catch (error) {
// do nth
}
};
})();
const router = createBrowserRouter([
{
path: "/auth",
element: <Auth />,
loader: async () => {
try {
await initialGlobalState();
} catch (error) {
// do nth
}
await initialGlobalStateLoader();
return null;
},
},
@ -28,8 +40,9 @@ const router = createBrowserRouter([
path: "/",
element: <Home />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialGlobalState();
await initialUserState();
} catch (error) {
// do nth
@ -48,8 +61,9 @@ const router = createBrowserRouter([
path: "/u/:userId",
element: <Home />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialGlobalState();
await initialUserState();
} catch (error) {
// do nth
@ -66,8 +80,9 @@ const router = createBrowserRouter([
path: "/explore",
element: <Explore />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialGlobalState();
await initialUserState();
} catch (error) {
// do nth
@ -84,8 +99,9 @@ const router = createBrowserRouter([
path: "/m/:memoId",
element: <MemoDetail />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialGlobalState();
await initialUserState();
} catch (error) {
// do nth
@ -102,8 +118,9 @@ const router = createBrowserRouter([
path: "/m/:memoId/embed",
element: <EmbedMemo />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialGlobalState();
await initialUserState();
} catch (error) {
// do nth
@ -115,11 +132,7 @@ const router = createBrowserRouter([
path: "*",
element: <NotFound />,
loader: async () => {
try {
await initialGlobalState();
} catch (error) {
// do nth
}
await initialGlobalStateLoader();
return null;
},
},

Loading…
Cancel
Save