mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	protection against deleting root note
This commit is contained in:
		
							parent
							
								
									0442a44aab
								
							
						
					
					
						commit
						ce9805c5bc
					
				| @ -59,6 +59,8 @@ async function moveToNode(nodesToMove, toNode) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function deleteNodes(nodes) { | async function deleteNodes(nodes) { | ||||||
|  |     nodes = nodes.filter(node => node.data.noteId !== 'root'); | ||||||
|  | 
 | ||||||
|     if (nodes.length === 0 || !confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { |     if (nodes.length === 0 || !confirm('Are you sure you want to delete select note(s) and all the sub-notes?')) { | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -248,6 +248,10 @@ async function deleteNote(branch) { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (branch.branchId === 'root' || branch.noteId === 'root') { | ||||||
|  |         throw new Error("Can't delete root branch/note"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     branch.isDeleted = true; |     branch.isDeleted = true; | ||||||
|     await branch.save(); |     await branch.save(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ async function validateParentChild(parentNoteId, childNoteId, branchId = null) { | |||||||
|     if (!await checkTreeCycle(parentNoteId, childNoteId)) { |     if (!await checkTreeCycle(parentNoteId, childNoteId)) { | ||||||
|         return { |         return { | ||||||
|             success: false, |             success: false, | ||||||
|             message: 'Moving note here would create cycle.' |             message: 'Moving/cloning note here would create cycle.' | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner