mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add username to cache key
This commit is contained in:
@ -6,6 +6,7 @@ import useLocalStorage from "react-use/lib/useLocalStorage";
|
|||||||
import { memoServiceClient } from "@/grpcweb";
|
import { memoServiceClient } from "@/grpcweb";
|
||||||
import { TAB_SPACE_WIDTH, UNKNOWN_ID } from "@/helpers/consts";
|
import { TAB_SPACE_WIDTH, UNKNOWN_ID } from "@/helpers/consts";
|
||||||
import { isValidUrl } from "@/helpers/utils";
|
import { isValidUrl } from "@/helpers/utils";
|
||||||
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { useGlobalStore, useResourceStore, useTagStore } from "@/store/module";
|
import { useGlobalStore, useResourceStore, useTagStore } from "@/store/module";
|
||||||
import { useMemoStore, useUserStore } from "@/store/v1";
|
import { useMemoStore, useUserStore } from "@/store/v1";
|
||||||
import { MemoRelation, MemoRelation_Type } from "@/types/proto/api/v2/memo_relation_service";
|
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 { className, editorClassName, cacheKey, memoId, parentMemoId, autoFocus, onConfirm } = props;
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const contentCacheKey = `memo-editor-${cacheKey}`;
|
|
||||||
const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
|
|
||||||
const {
|
const {
|
||||||
state: { systemStatus },
|
state: { systemStatus },
|
||||||
} = useGlobalStore();
|
} = useGlobalStore();
|
||||||
@ -59,6 +58,7 @@ const MemoEditor = (props: Props) => {
|
|||||||
const memoStore = useMemoStore();
|
const memoStore = useMemoStore();
|
||||||
const resourceStore = useResourceStore();
|
const resourceStore = useResourceStore();
|
||||||
const tagStore = useTagStore();
|
const tagStore = useTagStore();
|
||||||
|
const currentUser = useCurrentUser();
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
memoVisibility: Visibility.PRIVATE,
|
memoVisibility: Visibility.PRIVATE,
|
||||||
resourceList: [],
|
resourceList: [],
|
||||||
@ -69,6 +69,8 @@ const MemoEditor = (props: Props) => {
|
|||||||
const [hasContent, setHasContent] = useState<boolean>(false);
|
const [hasContent, setHasContent] = useState<boolean>(false);
|
||||||
const editorRef = useRef<EditorRefActions>(null);
|
const editorRef = useRef<EditorRefActions>(null);
|
||||||
const userSetting = userStore.userSetting as UserSetting;
|
const userSetting = userStore.userSetting as UserSetting;
|
||||||
|
const contentCacheKey = `${currentUser.name}-${cacheKey || ""}`;
|
||||||
|
const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");
|
||||||
const referenceRelations = memoId
|
const referenceRelations = memoId
|
||||||
? state.relationList.filter(
|
? state.relationList.filter(
|
||||||
(relation) => relation.memoId === memoId && relation.relatedMemoId !== memoId && relation.type === MemoRelation_Type.REFERENCE,
|
(relation) => relation.memoId === memoId && relation.relatedMemoId !== memoId && relation.type === MemoRelation_Type.REFERENCE,
|
||||||
|
Reference in New Issue
Block a user