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: code clean

Steven9faee68dabed
diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx
index 2d4fb8d8a..8fa60fcad 100644
--- a/web/src/components/MemoEditor/index.tsx
+++ b/web/src/components/MemoEditor/index.tsx
@@ -5,10 +5,9 @@ import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import useLocalStorage from "react-use/lib/useLocalStorage";
import { TAB_SPACE_WIDTH, UNKNOWN_ID, VISIBILITY_SELECTOR_ITEMS } from "@/helpers/consts";
-import { clearContentQueryParam } from "@/helpers/utils";
import useCurrentUser from "@/hooks/useCurrentUser";
import { getMatchedNodes } from "@/labs/marked";
-import { useFilterStore, useGlobalStore, useMemoStore, useResourceStore, useTagStore } from "@/store/module";
+import { useGlobalStore, useMemoStore, useResourceStore, useTagStore } from "@/store/module";
import { useUserV1Store } from "@/store/v1";
import { Resource } from "@/types/proto/api/v2/resource_service";
import { UserSetting, User_Role } from "@/types/proto/api/v2/user_service";
@@ -52,7 +51,6 @@ const MemoEditor = (props: Props) => {
state: { systemStatus },
} = useGlobalStore();
const userV1Store = useUserV1Store();
- const filterStore = useFilterStore();
const memoStore = useMemoStore();
const tagStore = useTagStore();
const resourceStore = useResourceStore();
@@ -324,10 +322,8 @@ const MemoEditor = (props: Props) => {
resourceIdList: state.resourceList.map((resource) => resource.id),
relationList: state.relationList,
});
- filterStore.clearFilter();
}
editorRef.current?.setContent("");
- clearContentQueryParam();
} catch (error: any) {
console.error(error);
toast.error(error.response.data.message);
diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx
index b8784cbe9..5883701ab 100644
--- a/web/src/components/MemoList.tsx
+++ b/web/src/components/MemoList.tsx
@@ -64,7 +64,7 @@ const MemoList: React.FC = () => {
return shouldShow;
})
: memos
- ).filter((memo) => memo.creatorUsername === username && memo.rowStatus === "NORMAL" && !memo.parent);
+ ).filter((memo) => memo.creatorUsername === username && memo.rowStatus === "NORMAL");
const pinnedMemos = shownMemos.filter((m) => m.pinned);
const unpinnedMemos = shownMemos.filter((m) => !m.pinned);
diff --git a/web/src/components/Settings/PreferencesSection.tsx b/web/src/components/Settings/PreferencesSection.tsx
index 759dc2025..3ff7ad72b 100644
--- a/web/src/components/Settings/PreferencesSection.tsx
+++ b/web/src/components/Settings/PreferencesSection.tsx
@@ -1,13 +1,14 @@
import { Button, Divider, Input, Option, Select } from "@mui/joy";
import { useState } from "react";
import { toast } from "react-hot-toast";
+import { Link } from "react-router-dom";
import { VISIBILITY_SELECTOR_ITEMS } from "@/helpers/consts";
import { useGlobalStore } from "@/store/module";
import { useUserV1Store } from "@/store/v1";
import { UserSetting } from "@/types/proto/api/v2/user_service";
import { useTranslate } from "@/utils/i18n";
import AppearanceSelect from "../AppearanceSelect";
-import LearnMore from "../LearnMore";
+import Icon from "../Icon";
import LocaleSelect from "../LocaleSelect";
import VisibilityIcon from "../VisibilityIcon";
import WebhookSection from "./WebhookSection";
@@ -103,25 +104,36 @@ const PreferencesSection = () => {
<Divider className="!mt-3 !my-4" />
- <div className="mb-2 w-full flex flex-row justify-between items-center">
- <div className="w-auto flex items-center">
- <span className="text-sm mr-1">{t("setting.preference-section.telegram-user-id")}</span>
- <LearnMore url="https://usememos.com/docs/integration/telegram-bot" />
+ <div className="w-full flex flex-col justify-start items-start">
+ <div className="mb-2 w-full flex flex-row justify-between items-center">
+ <div className="w-auto flex items-center">
+ <span className="text-sm mr-1">{t("setting.preference-section.telegram-user-id")}</span>
+ </div>
+ <Button variant="outlined" color="neutral" onClick={handleSaveTelegramUserId}>
+ {t("common.save")}
+ </Button>
+ </div>
+ <Input
+ className="w-full"
+ sx={{
+ fontFamily: "monospace",
+ fontSize: "14px",
+ }}
+ value={telegramUserId}
+ onChange={(event) => handleTelegramUserIdChanged(event.target.value)}
+ placeholder={t("setting.preference-section.telegram-user-id-placeholder")}
+ />
+ <div className="w-full">
+ <Link
+ className="text-gray-500 text-sm inline-flex flex-row justify-start items-center mt-2 hover:underline hover:text-blue-600"
+ to="https://usememos.com/docs/integration/telegram-bot"
+ target="_blank"
+ >
+ {t("common.learn-more")}
+ <Icon.ExternalLink className="inline w-4 h-auto ml-1" />
+ </Link>
</div>
- <Button variant="outlined" color="neutral" onClick={handleSaveTelegramUserId}>
- {t("common.save")}
- </Button>
</div>
- <Input
- className="w-full"
- sx={{
- fontFamily: "monospace",
- fontSize: "14px",
- }}
- value={telegramUserId}
- onChange={(event) => handleTelegramUserIdChanged(event.target.value)}
- placeholder={t("setting.preference-section.telegram-user-id-placeholder")}
- />
<Divider className="!my-4" />
diff --git a/web/src/components/Settings/SystemSection.tsx b/web/src/components/Settings/SystemSection.tsx
index b119fa00c..0310fae86 100644
--- a/web/src/components/Settings/SystemSection.tsx
+++ b/web/src/components/Settings/SystemSection.tsx
@@ -9,7 +9,6 @@ import { useTranslate } from "@/utils/i18n";
import { showCommonDialog } from "../Dialog/CommonDialog";
import showDisablePasswordLoginDialog from "../DisablePasswordLoginDialog";
import Icon from "../Icon";
-import LearnMore from "../LearnMore";
import showUpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
import "@/less/settings/system-section.less";
@@ -319,10 +318,6 @@ const SystemSection = () => {
<div className="flex flex-row items-center">
<div className="w-auto flex items-center">
<span className="text-sm mr-1">{t("setting.system-section.telegram-bot-token")}</span>
- <LearnMore
- url="https://usememos.com/docs/integration/telegram-bot"
- title={t("setting.system-section.telegram-bot-token-description")}
- />
</div>
</div>
<Button variant="outlined" color="neutral" onClick={handleSaveTelegramBotToken}>
@@ -339,6 +334,16 @@ const SystemSection = () => {
value={telegramBotToken}
onChange={(event) => handleTelegramBotTokenChanged(event.target.value)}
/>
+ <div className="w-full">
+ <Link
+ className="text-gray-500 text-sm inline-flex flex-row justify-start items-center mt-2 hover:underline hover:text-blue-600"
+ to="https://usememos.com/docs/integration/telegram-bot"
+ target="_blank"
+ >
+ {t("common.learn-more")}
+ <Icon.ExternalLink className="inline w-4 h-auto ml-1" />
+ </Link>
+ </div>
<Divider className="!mt-3 !my-4" />
<div className="form-label">
<span className="normal-text">{t("setting.system-section.additional-style")}</span>
diff --git a/web/src/helpers/utils.ts b/web/src/helpers/utils.ts
index c5982c026..b03b20c83 100644
--- a/web/src/helpers/utils.ts
+++ b/web/src/helpers/utils.ts
@@ -83,13 +83,3 @@ export const formatBytes = (bytes: number) => {
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
};
-
-export const clearContentQueryParam = () => {
- const urlParams = new URLSearchParams(window.location.search);
- urlParams.delete("content");
- let url = window.location.pathname;
- if (urlParams.toString()) {
- url += `?${urlParams.toString()}`;
- }
- window.history.replaceState({}, "", url);
-};
diff --git a/web/src/pages/Explore.tsx b/web/src/pages/Explore.tsx
index f781c88df..e1adffb15 100644
--- a/web/src/pages/Explore.tsx
+++ b/web/src/pages/Explore.tsx
@@ -49,7 +49,7 @@ const Explore = () => {
: memos;
const sortedMemos = fetchedMemos
- .filter((m) => m.rowStatus === "NORMAL" && m.visibility !== "PRIVATE" && !m.parent)
+ .filter((m) => m.rowStatus === "NORMAL" && m.visibility !== "PRIVATE")
.sort((mi, mj) => mj.displayTs - mi.displayTs);
useEffect(() => {
diff --git a/web/src/pages/Setting.tsx b/web/src/pages/Setting.tsx
index 646bfbe06..052f2434b 100644
--- a/web/src/pages/Setting.tsx
+++ b/web/src/pages/Setting.tsx
@@ -1,6 +1,5 @@
import { Option, Select } from "@mui/joy";
import { useState } from "react";
-import BetaBadge from "@/components/BetaBadge";
import Icon from "@/components/Icon";
import MobileHeader from "@/components/MobileHeader";
import MemberSection from "@/components/Settings/MemberSection";
@@ -82,13 +81,13 @@ const Setting = () => {
onClick={() => handleSectionSelectorItemClick("storage")}
className={`section-item ${state.selectedSection === "storage" ? "selected" : ""}`}
>
- <Icon.Database className="w-4 h-auto mr-2 opacity-80" /> {t("setting.storage")} <BetaBadge />
+ <Icon.Database className="w-4 h-auto mr-2 opacity-80" /> {t("setting.storage")}
</span>
<span
onClick={() => handleSectionSelectorItemClick("sso")}
className={`section-item ${state.selectedSection === "sso" ? "selected" : ""}`}
>
- <Icon.Key className="w-4 h-auto mr-2 opacity-80" /> {t("setting.sso")} <BetaBadge />
+ <Icon.Key className="w-4 h-auto mr-2 opacity-80" /> {t("setting.sso")}
</span>
</div>
</>