mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
refactor(react/dialogs): deduplicate data types
This commit is contained in:
parent
7a0f148d28
commit
0af5feab79
@ -1,4 +1,4 @@
|
|||||||
import { NoteType } from "@triliumnext/commons";
|
import type { FullRevision, RevisionItem } from "@triliumnext/commons";
|
||||||
import appContext, { EventData } from "../../components/app_context";
|
import appContext, { EventData } from "../../components/app_context";
|
||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
import dialog, { closeActiveDialog, openDialog } from "../../services/dialog";
|
import dialog, { closeActiveDialog, openDialog } from "../../services/dialog";
|
||||||
@ -21,22 +21,6 @@ interface RevisionsDialogProps {
|
|||||||
note?: FNote;
|
note?: FNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RevisionItem {
|
|
||||||
noteId: string;
|
|
||||||
revisionId: string;
|
|
||||||
dateLastEdited: string;
|
|
||||||
contentLength: number;
|
|
||||||
type: NoteType;
|
|
||||||
title: string;
|
|
||||||
isProtected: boolean;
|
|
||||||
mime: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FullRevision {
|
|
||||||
content: string;
|
|
||||||
mime: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function RevisionsDialogComponent({ note }: RevisionsDialogProps) {
|
function RevisionsDialogComponent({ note }: RevisionsDialogProps) {
|
||||||
const [ revisions, setRevisions ] = useState<RevisionItem[]>([]);
|
const [ revisions, setRevisions ] = useState<RevisionItem[]>([]);
|
||||||
const [ currentRevision, setCurrentRevision ] = useState<RevisionItem>();
|
const [ currentRevision, setCurrentRevision ] = useState<RevisionItem>();
|
||||||
|
@ -12,7 +12,7 @@ import ValidationError from "../../errors/validation_error.js";
|
|||||||
import blobService from "../../services/blob.js";
|
import blobService from "../../services/blob.js";
|
||||||
import type { Request } from "express";
|
import type { Request } from "express";
|
||||||
import type BBranch from "../../becca/entities/bbranch.js";
|
import type BBranch from "../../becca/entities/bbranch.js";
|
||||||
import type { AttributeRow } from "@triliumnext/commons";
|
import type { AttributeRow, DeleteNotesPreview } from "@triliumnext/commons";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
@ -339,7 +339,7 @@ function getDeleteNotesPreview(req: Request) {
|
|||||||
return {
|
return {
|
||||||
noteIdsToBeDeleted: Array.from(noteIdsToBeDeleted),
|
noteIdsToBeDeleted: Array.from(noteIdsToBeDeleted),
|
||||||
brokenRelations
|
brokenRelations
|
||||||
};
|
} satisfies DeleteNotesPreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
function forceSaveRevision(req: Request) {
|
function forceSaveRevision(req: Request) {
|
||||||
|
@ -12,6 +12,7 @@ import type { Request, Response } from "express";
|
|||||||
import type BRevision from "../../becca/entities/brevision.js";
|
import type BRevision from "../../becca/entities/brevision.js";
|
||||||
import type BNote from "../../becca/entities/bnote.js";
|
import type BNote from "../../becca/entities/bnote.js";
|
||||||
import type { NotePojo } from "../../becca/becca-interface.js";
|
import type { NotePojo } from "../../becca/becca-interface.js";
|
||||||
|
import { RevisionItem, RevisionRow } from "@triliumnext/commons";
|
||||||
|
|
||||||
interface NotePath {
|
interface NotePath {
|
||||||
noteId: string;
|
noteId: string;
|
||||||
@ -41,7 +42,7 @@ function getRevisions(req: Request) {
|
|||||||
WHERE revisions.noteId = ?
|
WHERE revisions.noteId = ?
|
||||||
ORDER BY revisions.utcDateCreated DESC`,
|
ORDER BY revisions.utcDateCreated DESC`,
|
||||||
[req.params.noteId]
|
[req.params.noteId]
|
||||||
);
|
) satisfies RevisionItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRevision(req: Request) {
|
function getRevision(req: Request) {
|
||||||
@ -59,7 +60,7 @@ function getRevision(req: Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return revision;
|
return revision satisfies RevisionRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRevisionFilename(revision: BRevision) {
|
function getRevisionFilename(revision: BRevision) {
|
||||||
|
@ -28,10 +28,10 @@ export interface RevisionRow {
|
|||||||
title: string;
|
title: string;
|
||||||
blobId?: string;
|
blobId?: string;
|
||||||
dateLastEdited?: string;
|
dateLastEdited?: string;
|
||||||
dateCreated: string;
|
dateCreated?: string;
|
||||||
utcDateLastEdited?: string;
|
utcDateLastEdited?: string;
|
||||||
utcDateCreated: string;
|
utcDateCreated: string;
|
||||||
utcDateModified: string;
|
utcDateModified?: string;
|
||||||
contentLength?: number;
|
contentLength?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AttributeRow } from "./rows.js";
|
import { AttributeRow, NoteType } from "./rows.js";
|
||||||
|
|
||||||
export interface AppInfo {
|
export interface AppInfo {
|
||||||
appVersion: string;
|
appVersion: string;
|
||||||
@ -17,3 +17,14 @@ export interface DeleteNotesPreview {
|
|||||||
noteIdsToBeDeleted: string[];
|
noteIdsToBeDeleted: string[];
|
||||||
brokenRelations: AttributeRow[];
|
brokenRelations: AttributeRow[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RevisionItem {
|
||||||
|
noteId: string;
|
||||||
|
revisionId?: string;
|
||||||
|
dateLastEdited?: string;
|
||||||
|
contentLength?: number;
|
||||||
|
type: NoteType;
|
||||||
|
title: string;
|
||||||
|
isProtected?: boolean;
|
||||||
|
mime: string;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user