Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update initial global loader

Steven3ff4d197821b
diff --git a/web/public/manifest.json b/web/public/manifest.json
index 5a3982ad4..5b74785cb 100644
--- a/web/public/manifest.json
+++ b/web/public/manifest.json
@@ -1,6 +1,6 @@
{
- "short_name": "Memos",
- "name": "Memos",
+ "short_name": "memos",
+ "name": "memos",
"description": "usememos/memos",
"icons": [
{
diff --git a/web/src/locales/en.json b/web/src/locales/en.json
index faa58849e..8d27cbf1c 100644
--- a/web/src/locales/en.json
+++ b/web/src/locales/en.json
@@ -320,8 +320,8 @@
"days": "days"
},
"about": {
- "about-memos": "About Memos",
- "memos-description": "Memos is a web-based note-taking application that you can use to write, organize, and share notes.",
+ "about-memos": "About memos",
+ "memos-description": "memos is a web-based note-taking application that you can use to write, organize, and share notes.",
"no-server-description": "No description configured for this server.",
"powered-by": "Powered by",
"other-projects": "Other Projects"
diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx
index 3ff51f634..265042183 100644
--- a/web/src/router/index.tsx
+++ b/web/src/router/index.tsx
@@ -18,21 +18,14 @@ const Resources = lazy(() => import("@/pages/Resources"));
const Setting = lazy(() => import("@/pages/Setting"));
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 initialGlobalStateLoader = async () => {
+ try {
+ await initialGlobalState();
+ } catch (error) {
+ // do nth
+ }
+ return null;
+};
const initialUserStateLoader = async (redirectWhenNotFound = true) => {
let user = undefined;
@@ -52,10 +45,7 @@ const router = createBrowserRouter([
{
path: "/",
element: <App />,
- loader: async () => {
- await initialGlobalStateLoader();
- return null;
- },
+ loader: () => initialGlobalStateLoader(),
children: [
{
path: "/auth",
diff --git a/web/src/store/module/global.ts b/web/src/store/module/global.ts
index 48d253479..495a802ae 100644
--- a/web/src/store/module/global.ts
+++ b/web/src/store/module/global.ts
@@ -7,9 +7,10 @@ import store, { useAppSelector } from "../";
import { setAppearance, setGlobalState, setLocale } from "../reducer/global";
export const initialGlobalState = async () => {
+ const { locale: storageLocale, appearance: storageAppearance } = storage.get(["locale", "appearance"]);
const defaultGlobalState = {
- locale: "en" as Locale,
- appearance: "system" as Appearance,
+ locale: (storageLocale || "en") as Locale,
+ appearance: (storageAppearance || "system") as Appearance,
systemStatus: {
allowSignUp: false,
disablePasswordLogin: false,
@@ -30,14 +31,6 @@ export const initialGlobalState = async () => {
} as SystemStatus,
};
- const { locale: storageLocale, appearance: storageAppearance } = storage.get(["locale", "appearance"]);
- if (storageLocale) {
- defaultGlobalState.locale = storageLocale;
- }
- if (storageAppearance) {
- defaultGlobalState.appearance = storageAppearance;
- }
-
const { data } = await api.getSystemStatus();
if (data) {
const customizedProfile = data.customizedProfile;
@@ -53,8 +46,8 @@ export const initialGlobalState = async () => {
},
};
defaultGlobalState.locale =
- storageLocale || defaultGlobalState.systemStatus.customizedProfile.locale || findNearestLanguageMatch(i18n.language);
- defaultGlobalState.appearance = defaultGlobalState.systemStatus.customizedProfile.appearance;
+ defaultGlobalState.locale || defaultGlobalState.systemStatus.customizedProfile.locale || findNearestLanguageMatch(i18n.language);
+ defaultGlobalState.appearance = defaultGlobalState.appearance || defaultGlobalState.systemStatus.customizedProfile.appearance;
}
store.dispatch(setGlobalState(defaultGlobalState));
};