mirror of
https://github.com/zadam/trilium.git
synced 2025-11-26 02:24:23 +01:00
refactor(react/promoted_attributes): deduplicate server API typings
This commit is contained in:
parent
891e71aec6
commit
6a126009a8
@ -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<Cell[]>();
|
||||
@ -417,7 +412,7 @@ function buildPromotedAttributeLabelChangedListener({ note, cell, componentId, .
|
||||
}
|
||||
|
||||
function updateAttribute(note: FNote, cell: Cell, componentId: string, value: string) {
|
||||
return server.put<AttributeResult>(
|
||||
return server.put<UpdateAttributeResponse>(
|
||||
`notes/${note.noteId}/attribute`,
|
||||
{
|
||||
attributeId: cell.valueAttr.attributeId,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -273,3 +273,7 @@ export interface NoteMapPostResponse {
|
||||
links: NoteMapLink[];
|
||||
noteIdToDescendantCountMap: Record<string, number>;
|
||||
}
|
||||
|
||||
export interface UpdateAttributeResponse {
|
||||
attributeId: string;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user