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