mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 19:19:03 +01:00 
			
		
		
		
	chore(lint): improve type and get rid of "any"
This commit is contained in:
		
							parent
							
								
									0f0e55deb2
								
							
						
					
					
						commit
						dfb8982a99
					
				| @ -1618,7 +1618,7 @@ class BNote extends AbstractBeccaEntity<BNote> { | |||||||
|      * @param matchBy - choose by which property we detect if to update an existing attachment. |      * @param matchBy - choose by which property we detect if to update an existing attachment. | ||||||
|      *                      Supported values are either 'attachmentId' (default) or 'title' |      *                      Supported values are either 'attachmentId' (default) or 'title' | ||||||
|      */ |      */ | ||||||
|     saveAttachment({ attachmentId, role, mime, title, content, position }: AttachmentRow, matchBy = "attachmentId") { |     saveAttachment({ attachmentId, role, mime, title, content, position }: AttachmentRow, matchBy: "attachmentId" | "title" | undefined = "attachmentId") { | ||||||
|         if (!["attachmentId", "title"].includes(matchBy)) { |         if (!["attachmentId", "title"].includes(matchBy)) { | ||||||
|             throw new Error(`Unsupported value '${matchBy}' for matchBy param, has to be either 'attachmentId' or 'title'.`); |             throw new Error(`Unsupported value '${matchBy}' for matchBy param, has to be either 'attachmentId' or 'title'.`); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -33,7 +33,9 @@ function getAllAttachments(req: Request) { | |||||||
| function saveAttachment(req: Request) { | function saveAttachment(req: Request) { | ||||||
|     const { noteId } = req.params; |     const { noteId } = req.params; | ||||||
|     const { attachmentId, role, mime, title, content } = req.body; |     const { attachmentId, role, mime, title, content } = req.body; | ||||||
|     const { matchBy } = req.query as any; |     const matchByQuery = req.query.matchBy | ||||||
|  |     const isValidMatchBy = (typeof matchByQuery === "string") && (matchByQuery === "attachmentId" || matchByQuery === "title"); | ||||||
|  |     const matchBy = isValidMatchBy ? matchByQuery : undefined; | ||||||
| 
 | 
 | ||||||
|     const note = becca.getNoteOrThrow(noteId); |     const note = becca.getNoteOrThrow(noteId); | ||||||
|     note.saveAttachment({ attachmentId, role, mime, title, content }, matchBy); |     note.saveAttachment({ attachmentId, role, mime, title, content }, matchBy); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Panagiotis Papadopoulos
						Panagiotis Papadopoulos