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: add username to cache key

Steven89a270cedeba
diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsx
index 5ad6ac0a0..b8125b709 100644
--- a/web/src/components/MemoEditor/index.tsx
+++ b/web/src/components/MemoEditor/index.tsx
@@ -6,6 +6,7 @@ import useLocalStorage from "react-use/lib/useLocalStorage";
import { memoServiceClient } from "@/grpcweb";
import { TAB_SPACE_WIDTH, UNKNOWN_ID } from "@/helpers/consts";
import { isValidUrl } from "@/helpers/utils";
+import useCurrentUser from "@/hooks/useCurrentUser";
import { useGlobalStore, useResourceStore, useTagStore } from "@/store/module";
import { useMemoStore, useUserStore } from "@/store/v1";
import { MemoRelation, MemoRelation_Type } from "@/types/proto/api/v2/memo_relation_service";
@@ -50,8 +51,6 @@ const MemoEditor = (props: Props) => {
const { className, editorClassName, cacheKey, memoId, parentMemoId, autoFocus, onConfirm } = props;
const { i18n } = useTranslation();
const t = useTranslate();
- const contentCacheKey = `memo-editor-${cacheKey}`;
- const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
const {
state: { systemStatus },
} = useGlobalStore();
@@ -59,6 +58,7 @@ const MemoEditor = (props: Props) => {
const memoStore = useMemoStore();
const resourceStore = useResourceStore();
const tagStore = useTagStore();
+ const currentUser = useCurrentUser();
const [state, setState] = useState<State>({
memoVisibility: Visibility.PRIVATE,
resourceList: [],
@@ -69,6 +69,8 @@ const MemoEditor = (props: Props) => {
const [hasContent, setHasContent] = useState<boolean>(false);
const editorRef = useRef<EditorRefActions>(null);
const userSetting = userStore.userSetting as UserSetting;
+ const contentCacheKey = `${currentUser.name}-${cacheKey || ""}`;
+ const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
const referenceRelations = memoId
? state.relationList.filter(
(relation) => relation.memoId === memoId && relation.relatedMemoId !== memoId && relation.type === MemoRelation_Type.REFERENCE,