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
fix(frontend): ensure attachments are properly linked when creating memos (#5428)
lifcbbb585b2e9a
diff --git a/web/src/components/MemoEditor/services/memoService.ts b/web/src/components/MemoEditor/services/memoService.tsindex 204852ff0..53b553293 100644--- a/web/src/components/MemoEditor/services/memoService.ts+++ b/web/src/components/MemoEditor/services/memoService.ts@@ -2,11 +2,21 @@ import { create } from "@bufbuild/protobuf";import { FieldMaskSchema, timestampDate, timestampFromDate } from "@bufbuild/protobuf/wkt";import { isEqual } from "lodash-es";import { memoServiceClient } from "@/connect";+import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";+import { AttachmentSchema } from "@/types/proto/api/v1/attachment_service_pb";import type { Memo } from "@/types/proto/api/v1/memo_service_pb";import { MemoSchema } from "@/types/proto/api/v1/memo_service_pb";import type { EditorState } from "../state";import { uploadService } from "./uploadService";+/**+ * Converts attachments to reference format for API requests.+ * The backend only needs the attachment name to link it to a memo.+ */+function toAttachmentReferences(attachments: Attachment[]): Attachment[] {+ return attachments.map((a) => create(AttachmentSchema, { name: a.name }));+}+function buildUpdateMask(prevMemo: Memo,state: EditorState,@@ -28,7 +38,7 @@ function buildUpdateMask(}if (!isEqual(allAttachments, prevMemo.attachments)) {mask.add("attachments");- patch.attachments = allAttachments;+ patch.attachments = toAttachmentReferences(allAttachments);}if (!isEqual(state.metadata.relations, prevMemo.relations)) {mask.add("relations");@@ -95,7 +105,7 @@ export const memoService = {const memoData = create(MemoSchema, {content: state.content,visibility: state.metadata.visibility,- attachments: allAttachments,+ attachments: toAttachmentReferences(allAttachments),relations: state.metadata.relations,location: state.metadata.location,createTime: state.timestamps.createTime ? timestampFromDate(state.timestamps.createTime) : undefined,