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.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: tweak props naming
Stevenc7aaf791e690
diff --git a/web/src/components/MemoActionMenu.tsx b/web/src/components/MemoActionMenu.tsxindex a0b6a7cce..788b60bcd 100644--- a/web/src/components/MemoActionMenu.tsx+++ b/web/src/components/MemoActionMenu.tsx@@ -52,8 +52,8 @@ const MemoActionMenu = (props: Props) => {const handleEditMemoClick = () => {showMemoEditorDialog({- memoId: extractMemoIdFromName(memo.name),- cacheKey: `${memo.name}-${memo.updateTime}`,+ memoName: memo.name,+ cacheKey: `${memo.name}-${memo.displayTime}`,});};diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsxindex 07e2cae97..c9c3ca4f6 100644--- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx+++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx@@ -30,7 +30,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {if (!memo) {return <Error message={`Memo not found: ${resourceId}`} />;}- if (extractMemoIdFromName(memo.name) === context.memoId || context.embeddedMemos.has(resourceName)) {+ if (memo.name === context.memoName || context.embeddedMemos.has(resourceName)) {return <Error message={`Nested Rendering Error: ![[${resourceName}]]`} />;}@@ -43,7 +43,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {<div className="w-full"><MemoContentkey={`${memo.name}-${memo.updateTime}`}- memoId={extractMemoIdFromName(memo.name)}+ memoName={memo.name}content={memo.content}embeddedMemos={context.embeddedMemos}/>@@ -64,7 +64,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {</div><MemoContentkey={`${memo.name}-${memo.updateTime}`}- memoId={extractMemoIdFromName(memo.name)}+ memoName={memo.name}content={memo.content}embeddedMemos={context.embeddedMemos}/>diff --git a/web/src/components/MemoContent/TaskList.tsx b/web/src/components/MemoContent/TaskList.tsxindex 4ee104de6..47f5e9d79 100644--- a/web/src/components/MemoContent/TaskList.tsx+++ b/web/src/components/MemoContent/TaskList.tsx@@ -21,7 +21,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)const [checked] = useState(complete);const handleCheckboxChange = async (on: boolean) => {- if (context.readonly || !context.memoId) {+ if (context.readonly || !context.memoName) {return;}@@ -39,7 +39,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)const content = window.restore(context.nodes);await memoStore.updateMemo({- name: `${MemoNamePrefix}${context.memoId}`,+ name: `${MemoNamePrefix}${context.memoName}`,content,},["content"],diff --git a/web/src/components/MemoContent/index.tsx b/web/src/components/MemoContent/index.tsxindex f5b2918cd..c4092c9db 100644--- a/web/src/components/MemoContent/index.tsx+++ b/web/src/components/MemoContent/index.tsx@@ -12,7 +12,7 @@ const MAX_DISPLAY_HEIGHT = 256;interface Props {content: string;- memoId?: number;+ memoName?: string;compact?: boolean;readonly?: boolean;disableFilter?: boolean;@@ -24,13 +24,13 @@ interface Props {}const MemoContent: React.FC<Props> = (props: Props) => {- const { className, content, memoId, embeddedMemos, onClick } = props;+ const { className, content, memoName, embeddedMemos, onClick } = props;const t = useTranslate();const currentUser = useCurrentUser();const memoStore = useMemoStore();const memoContentContainerRef = useRef<HTMLDivElement>(null);const [showCompactMode, setShowCompactMode] = useState<boolean>(false);- const memo = memoId ? memoStore.getMemoByName(`${MemoNamePrefix}${memoId}`) : null;+ const memo = memoName ? memoStore.getMemoByName(memoName) : null;const nodes = window.parse(content);const allowEdit = !props.readonly && memo && currentUser?.name === memo.creator;@@ -62,7 +62,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {<RendererContext.Providervalue={{nodes,- memoId,+ memoName: memoName,readonly: !allowEdit,disableFilter: props.disableFilter,embeddedMemos: embeddedMemos || new Set(),diff --git a/web/src/components/MemoContent/types/context.ts b/web/src/components/MemoContent/types/context.tsindex b885df28e..3ed174b9a 100644--- a/web/src/components/MemoContent/types/context.ts+++ b/web/src/components/MemoContent/types/context.ts@@ -6,7 +6,7 @@ interface Context {// embeddedMemos is a set of memo resource names that are embedded in the current memo.// This is used to prevent infinite loops when a memo embeds itself.embeddedMemos: Set<string>;- memoId?: number;+ memoName?: string;readonly?: boolean;disableFilter?: boolean;}diff --git a/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx b/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsxindex 758cd8604..685ca72f6 100644--- a/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx+++ b/web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx@@ -47,12 +47,12 @@ const AddMemoRelationButton = (props: Props) => {uniqBy([...memos.map((memo) => ({- memo: `${MemoNamePrefix}${context.memoId || UNKNOWN_ID}`,+ memo: context.memoName || "",relatedMemo: memo.name,type: MemoRelation_Type.REFERENCE,})),...context.relationList,- ].filter((relation) => relation.relatedMemo !== `${MemoNamePrefix}${context.memoId || UNKNOWN_ID}`),+ ].filter((relation) => relation.relatedMemo !== context.memoName),"relatedMemoId",),);diff --git a/web/src/components/MemoEditor/MemoEditorDialog.tsx b/web/src/components/MemoEditor/MemoEditorDialog.tsxindex 95a942652..29c450683 100644--- a/web/src/components/MemoEditor/MemoEditorDialog.tsx+++ b/web/src/components/MemoEditor/MemoEditorDialog.tsx@@ -2,17 +2,17 @@ import { IconButton } from "@mui/joy";import { useEffect } from "react";import { useGlobalStore, useTagStore } from "@/store/module";import { MemoRelation } from "@/types/proto/api/v2/memo_relation_service";-import MemoEditorV1 from ".";+import MemoEditor from ".";import { generateDialog } from "../Dialog";import Icon from "../Icon";interface Props extends DialogProps {- memoId?: number;+ memoName?: string;cacheKey?: string;relationList?: MemoRelation[];}-const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, destroy }: Props) => {+const MemoEditorDialog: React.FC<Props> = ({ memoName: memo, cacheKey, relationList, destroy }: Props) => {const globalStore = useGlobalStore();const tagStore = useTagStore();const { systemStatus } = globalStore.state;@@ -37,10 +37,10 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des</IconButton></div><div className="flex flex-col justify-start items-start max-w-full w-[36rem]">- <MemoEditorV1+ <MemoEditorclassName="border-none !p-0 -mb-2"- cacheKey={`memo-editor-${cacheKey || memoId}`}- memoId={memoId}+ cacheKey={`memo-editor-${cacheKey || memo}`}+ memoName={memo}relationList={relationList}onConfirm={handleCloseBtnClick}autoFocus@@ -50,7 +50,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des);};-export default function showMemoEditorDialog(props: Pick<Props, "memoId" | "cacheKey" | "relationList"> = {}): void {+export default function showMemoEditorDialog(props: Pick<Props, "memoName" | "cacheKey" | "relationList"> = {}): void {generateDialog({className: "memo-editor-dialog",diff --git a/web/src/components/MemoEditor/index.tsx b/web/src/components/MemoEditor/index.tsxindex dbc7ed166..3398a8959 100644--- a/web/src/components/MemoEditor/index.tsx+++ b/web/src/components/MemoEditor/index.tsx@@ -30,13 +30,12 @@ import { MemoEditorContext } from "./types";interface Props {className?: string;- editorClassName?: string;cacheKey?: string;- memoId?: number;- parentMemoId?: number;+ memoName?: string;+ parentMemoName?: string;relationList?: MemoRelation[];autoFocus?: boolean;- onConfirm?: (memoId: number) => void;+ onConfirm?: (memoName: string) => void;onEditPrevious?: () => void;}@@ -50,7 +49,7 @@ interface State {}const MemoEditor = (props: Props) => {- const { className, editorClassName, cacheKey, memoId, parentMemoId, autoFocus, onConfirm } = props;+ const { className, cacheKey, memoName, parentMemoName, autoFocus, onConfirm } = props;const { i18n } = useTranslation();const t = useTranslate();const {@@ -74,12 +73,9 @@ const MemoEditor = (props: Props) => {const userSetting = userStore.userSetting as UserSetting;const contentCacheKey = `${currentUser.name}-${cacheKey || ""}`;const [contentCache, setContentCache] = useLocalStorage<string>(contentCacheKey, "");- const referenceRelations = memoId+ const referenceRelations = memoName? state.relationList.filter(- (relation) =>- extractMemoIdFromName(relation.memo) === memoId &&- extractMemoIdFromName(relation.relatedMemo) !== memoId &&- relation.type === MemoRelation_Type.REFERENCE,+ (relation) => relation.memo === memoName && relation.relatedMemo !== memoName && relation.type === MemoRelation_Type.REFERENCE,): state.relationList.filter((relation) => relation.type === MemoRelation_Type.REFERENCE);@@ -105,8 +101,8 @@ const MemoEditor = (props: Props) => {}, [userSetting.memoVisibility, systemStatus.disablePublicMemos]);useEffect(() => {- if (memoId) {- memoStore.getOrFetchMemoByName(`${MemoNamePrefix}${memoId}`).then((memo) => {+ if (memoName) {+ memoStore.getOrFetchMemoByName(memoName).then((memo) => {if (memo) {handleEditorFocus();setState((prevState) => ({@@ -121,7 +117,7 @@ const MemoEditor = (props: Props) => {}});}- }, [memoId]);+ }, [memoName]);const handleCompositionStart = () => {setState((prevState) => ({@@ -233,11 +229,11 @@ const MemoEditor = (props: Props) => {const resource = await handleUploadResource(file);if (resource) {uploadedResourceList.push(resource);- if (memoId) {+ if (memoName) {await resourceStore.updateResource({resource: Resource.fromPartial({name: resource.name,- memoId,+ memoId: extractMemoIdFromName(memoName),}),updateMask: ["memo_id"],});@@ -296,8 +292,8 @@ const MemoEditor = (props: Props) => {const content = editorRef.current?.getContent() ?? "";try {// Update memo.- if (memoId && memoId !== UNKNOWN_ID) {- const prevMemo = await memoStore.getOrFetchMemoByName(`${MemoNamePrefix}${memoId}`);+ if (memoName) {+ const prevMemo = await memoStore.getOrFetchMemoByName(memoName);if (prevMemo) {const memo = await memoStore.updateMemo({@@ -315,22 +311,21 @@ const MemoEditor = (props: Props) => {name: memo.name,relations: state.relationList,});- const memoId = extractMemoIdFromName(memo.name);- await memoStore.getOrFetchMemoByName(`${MemoNamePrefix}${memoId}`, { skipCache: true });+ await memoStore.getOrFetchMemoByName(memo.name, { skipCache: true });if (onConfirm) {- onConfirm(memoId);+ onConfirm(memo.name);}}} else {// Create memo or memo comment.- const request = !parentMemoId+ const request = !parentMemoName? memoStore.createMemo({content,visibility: state.memoVisibility,}): memoServiceClient.createMemoComment({- name: `${MemoNamePrefix}${parentMemoId}`,+ name: parentMemoName,comment: {content,visibility: state.memoVisibility,@@ -346,10 +341,9 @@ const MemoEditor = (props: Props) => {name: memo.name,relations: state.relationList,});- const memoId = extractMemoIdFromName(memo.name);- await memoStore.getOrFetchMemoByName(`${MemoNamePrefix}${memoId}`, { skipCache: true });+ await memoStore.getOrFetchMemoByName(memo.name, { skipCache: true });if (onConfirm) {- onConfirm(memoId);+ onConfirm(memo.name);}}editorRef.current?.setContent("");@@ -378,7 +372,7 @@ const MemoEditor = (props: Props) => {const editorConfig = useMemo(() => ({- className: editorClassName ?? "",+ className: "",initialContent: "",placeholder: t("editor.placeholder"),onContentChange: handleContentChange,@@ -399,7 +393,7 @@ const MemoEditor = (props: Props) => {relationList,}));},- memoId,+ memoName,}}><divdiff --git a/web/src/components/MemoEditor/types/context.ts b/web/src/components/MemoEditor/types/context.tsindex 7bd2fa0eb..a67079eb8 100644--- a/web/src/components/MemoEditor/types/context.ts+++ b/web/src/components/MemoEditor/types/context.ts@@ -4,8 +4,7 @@ import { MemoRelation } from "@/types/proto/api/v2/memo_relation_service";interface Context {relationList: MemoRelation[];setRelationList: (relationList: MemoRelation[]) => void;- // memoId is the id of the memo that is being edited.- memoId?: number;+ memoName?: string;}export const MemoEditorContext = createContext<Context>({diff --git a/web/src/components/MemoRelationListView.tsx b/web/src/components/MemoRelationListView.tsxindex b6cb6a92a..56a7d3b0f 100644--- a/web/src/components/MemoRelationListView.tsx+++ b/web/src/components/MemoRelationListView.tsx@@ -63,7 +63,7 @@ const MemoRelationListView = (props: Props) => {<div key={memo.name} className="block w-auto max-w-[50%]"><LinkclassName="px-2 border rounded-md w-auto text-sm leading-6 flex flex-row justify-start items-center flex-nowrap text-gray-600 dark:text-gray-400 dark:border-zinc-700 dark:bg-zinc-900 hover:shadow hover:opacity-80"- to={`/m/${memo.name}`}+ to={`/m/${memo.uid}`}unstable_viewTransition><Tooltip title="Backlink" placement="top">diff --git a/web/src/components/MemoView.tsx b/web/src/components/MemoView.tsxindex fe05c33a8..c8eeb5a8e 100644--- a/web/src/components/MemoView.tsx+++ b/web/src/components/MemoView.tsx@@ -144,7 +144,7 @@ const MemoView: React.FC<Props> = (props: Props) => {</div><MemoContentkey={`${memo.name}-${memo.updateTime}`}- memoId={extractMemoIdFromName(memo.name)}+ memoName={memo.name}content={memo.content}readonly={readonly}onClick={handleMemoContentClick}diff --git a/web/src/components/ShareMemoDialog.tsx b/web/src/components/ShareMemoDialog.tsxindex 218c6066b..860d55485 100644--- a/web/src/components/ShareMemoDialog.tsx+++ b/web/src/components/ShareMemoDialog.tsx@@ -155,7 +155,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {><span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{getDateTimeString(memo.displayTime)}</span><div className="w-full px-6 text-base pb-4 space-y-2">- <MemoContent memoId={extractMemoIdFromName(memo.name)} content={memo.content} readonly={true} disableFilter />+ <MemoContent memoName={memo.name} content={memo.content} readonly={true} disableFilter /><MemoResourceListView resources={memo.resources} /></div><div className="flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6">diff --git a/web/src/pages/Archived.tsx b/web/src/pages/Archived.tsxindex 2e074045c..01b5af495 100644--- a/web/src/pages/Archived.tsx+++ b/web/src/pages/Archived.tsx@@ -99,7 +99,7 @@ const Archived = () => {<MemoFilter className="px-2 pb-2" />{sortedMemos.map((memo) => (<div- key={extractMemoIdFromName(memo.name)}+ key={memo.name}className="relative flex flex-col justify-start items-start w-full p-4 pt-3 mb-2 bg-white dark:bg-zinc-800 rounded-lg"><div className="w-full mb-1 flex flex-row justify-between items-center">@@ -121,12 +121,7 @@ const Archived = () => {</Tooltip></div></div>- <MemoContent- key={`${memo.name}-${memo.displayTime}`}- memoId={extractMemoIdFromName(memo.name)}- content={memo.content}- readonly={true}- />+ <MemoContent key={`${memo.name}-${memo.displayTime}`} memoName={memo.name} content={memo.content} readonly={true} /></div>))}{isRequesting ? (diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsxindex 5041a0308..eb0e4c13a 100644--- a/web/src/pages/Home.tsx+++ b/web/src/pages/Home.tsx@@ -63,8 +63,8 @@ const Home = () => {const handleEditPrevious = useCallback(() => {const lastMemo = memoList.value[memoList.value.length - 1];showMemoEditorDialog({- memoId: extractMemoIdFromName(lastMemo.name),- cacheKey: `${lastMemo.name}-${lastMemo.updateTime}`,+ memoName: lastMemo.name,+ cacheKey: `${lastMemo.name}-${lastMemo.displayTime}`,});}, [memoList]);diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsxindex f7fdb6ab7..3fa52da1a 100644--- a/web/src/pages/MemoDetail.tsx+++ b/web/src/pages/MemoDetail.tsx@@ -60,8 +60,8 @@ const MemoDetail = () => {return null;}- const handleCommentCreated = async (commentId: number) => {- await memoStore.getOrFetchMemoByName(`${MemoNamePrefix}${commentId}`);+ const handleCommentCreated = async (memoCommentName: string) => {+ await memoStore.getOrFetchMemoByName(memoCommentName);await memoStore.getOrFetchMemoByName(memo.name, { skipCache: true });};@@ -117,7 +117,7 @@ const MemoDetail = () => {<MemoEditorkey={memo.name}cacheKey={`comment-editor-${memo.name}`}- parentMemoId={extractMemoIdFromName(memo.name)}+ parentMemoName={memo.name}onConfirm={handleCommentCreated}/>)}diff --git a/web/src/pages/Resources.tsx b/web/src/pages/Resources.tsxindex a58c8df4e..78b83a8ee 100644--- a/web/src/pages/Resources.tsx+++ b/web/src/pages/Resources.tsx@@ -48,9 +48,9 @@ const Resources = () => {});const memoStore = useMemoStore();const [resources, setResources] = useState<Resource[]>([]);- const filteredResources = resources.filter((resource: any) => includes(resource.filename, state.searchQuery));- const groupedResources = groupResourcesByDate(filteredResources.filter((resource: any) => resource.memoId));- const unusedResources = filteredResources.filter((resource: any) => !resource.memoId);+ const filteredResources = resources.filter((resource) => includes(resource.filename, state.searchQuery));+ const groupedResources = groupResourcesByDate(filteredResources.filter((resource) => resource.memoId));+ const unusedResources = filteredResources.filter((resource) => !resource.memoId);useEffect(() => {resourceServiceClient.listResources({}).then(({ resources }) => {