diff --git a/apps/client/src/widgets/PromotedAttributes.tsx b/apps/client/src/widgets/PromotedAttributes.tsx index 73d5f0b81..42296e7ba 100644 --- a/apps/client/src/widgets/PromotedAttributes.tsx +++ b/apps/client/src/widgets/PromotedAttributes.tsx @@ -12,6 +12,7 @@ import { ComponentChild, HTMLInputTypeAttribute, InputHTMLAttributes, MouseEvent import tree from "../services/tree"; import NoteAutocomplete from "./react/NoteAutocomplete"; import ws from "../services/ws"; +import { UpdateAttributeResponse } from "@triliumnext/commons"; interface Cell { definitionAttr: FAttribute; @@ -30,12 +31,6 @@ interface CellProps { setCellToFocus(cell: Cell): void; } -// TODO: Deduplicate -interface AttributeResult { - attributeId: string; -} - - export default function PromotedAttributes() { const { note, componentId } = useNoteContext(); const [ cells, setCells ] = useState(); @@ -417,7 +412,7 @@ function buildPromotedAttributeLabelChangedListener({ note, cell, componentId, . } function updateAttribute(note: FNote, cell: Cell, componentId: string, value: string) { - return server.put( + return server.put( `notes/${note.noteId}/attribute`, { attributeId: cell.valueAttr.attributeId, diff --git a/apps/server/src/routes/api/attributes.ts b/apps/server/src/routes/api/attributes.ts index fa106180b..55c3e3e29 100644 --- a/apps/server/src/routes/api/attributes.ts +++ b/apps/server/src/routes/api/attributes.ts @@ -7,6 +7,7 @@ import BAttribute from "../../becca/entities/battribute.js"; import becca from "../../becca/becca.js"; import ValidationError from "../../errors/validation_error.js"; import type { Request } from "express"; +import { UpdateAttributeResponse } from "@triliumnext/commons"; function getEffectiveNoteAttributes(req: Request) { const note = becca.getNote(req.params.noteId); @@ -18,7 +19,7 @@ function updateNoteAttribute(req: Request) { const noteId = req.params.noteId; const body = req.body; - let attribute; + let attribute: BAttribute; if (body.attributeId) { attribute = becca.getAttributeOrThrow(body.attributeId); @@ -64,7 +65,7 @@ function updateNoteAttribute(req: Request) { return { attributeId: attribute.attributeId - }; + } satisfies UpdateAttributeResponse; } function setNoteAttribute(req: Request) { diff --git a/packages/commons/src/lib/server_api.ts b/packages/commons/src/lib/server_api.ts index dc6dc4d41..1e79c2151 100644 --- a/packages/commons/src/lib/server_api.ts +++ b/packages/commons/src/lib/server_api.ts @@ -273,3 +273,7 @@ export interface NoteMapPostResponse { links: NoteMapLink[]; noteIdToDescendantCountMap: Record; } + +export interface UpdateAttributeResponse { + attributeId: string; +}