From d29c40dc7106a50f0dd7455f1154d8b45c47f68d Mon Sep 17 00:00:00 2001 From: boojack Date: Fri, 17 Feb 2023 08:26:40 +0800 Subject: [PATCH] chore: update router loader (#1102) --- web/src/components/Settings/SystemSection.tsx | 4 -- web/src/i18n.ts | 2 +- web/src/router/index.tsx | 43 ++++++++++++------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/web/src/components/Settings/SystemSection.tsx b/web/src/components/Settings/SystemSection.tsx index be4a64ab..51561597 100644 --- a/web/src/components/Settings/SystemSection.tsx +++ b/web/src/components/Settings/SystemSection.tsx @@ -157,10 +157,6 @@ const SystemSection = () => { {t("setting.system-section.disable-public-memos")} handleDisablePublicMemosChanged(event.target.checked)} /> -
- Storage - handleDisablePublicMemosChanged(event.target.checked)} /> -
{t("setting.system-section.additional-style")} diff --git a/web/src/i18n.ts b/web/src/i18n.ts index 41873cf2..5430836a 100644 --- a/web/src/i18n.ts +++ b/web/src/i18n.ts @@ -52,7 +52,7 @@ i18n.use(initReactI18next).init({ translation: hantLocale, }, }, - lng: "nl", + lng: "en", fallbackLng: "en", }); diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index b9748c83..36a4e795 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -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: , loader: async () => { - try { - await initialGlobalState(); - } catch (error) { - // do nth - } + await initialGlobalStateLoader(); return null; }, }, @@ -28,8 +40,9 @@ const router = createBrowserRouter([ path: "/", element: , loader: async () => { + await initialGlobalStateLoader(); + try { - await initialGlobalState(); await initialUserState(); } catch (error) { // do nth @@ -48,8 +61,9 @@ const router = createBrowserRouter([ path: "/u/:userId", element: , loader: async () => { + await initialGlobalStateLoader(); + try { - await initialGlobalState(); await initialUserState(); } catch (error) { // do nth @@ -66,8 +80,9 @@ const router = createBrowserRouter([ path: "/explore", element: , loader: async () => { + await initialGlobalStateLoader(); + try { - await initialGlobalState(); await initialUserState(); } catch (error) { // do nth @@ -84,8 +99,9 @@ const router = createBrowserRouter([ path: "/m/:memoId", element: , 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: , loader: async () => { + await initialGlobalStateLoader(); + try { - await initialGlobalState(); await initialUserState(); } catch (error) { // do nth @@ -115,11 +132,7 @@ const router = createBrowserRouter([ path: "*", element: , loader: async () => { - try { - await initialGlobalState(); - } catch (error) { - // do nth - } + await initialGlobalStateLoader(); return null; }, },