mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-30 12:13:52 +08:00 
			
		
		
		
	same event handling note execute only once, closes #1278
This commit is contained in:
		
							parent
							
								
									cabb78b3e4
								
							
						
					
					
						commit
						a665d193eb
					
				| @ -6,17 +6,15 @@ const repository = require('./repository'); | |||||||
| const Attribute = require('../entities/attribute'); | const Attribute = require('../entities/attribute'); | ||||||
| 
 | 
 | ||||||
| function runAttachedRelations(note, relationName, originEntity) { | function runAttachedRelations(note, relationName, originEntity) { | ||||||
|     const runRelations = note.getRelations(relationName); |     // same script note can get here with multiple ways, but execute only once
 | ||||||
|  |     const notesToRun = new Set( | ||||||
|  |         note.getRelations(relationName) | ||||||
|  |             .map(relation => relation.getTargetNote()) | ||||||
|  |             .filter(note => !!note) | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     for (const relation of runRelations) { |     for (const noteToRun of notesToRun) { | ||||||
|         const scriptNote = relation.getTargetNote(); |         scriptService.executeNoteNoException(noteToRun, { originEntity }); | ||||||
| 
 |  | ||||||
|         if (scriptNote) { |  | ||||||
|             scriptService.executeNoteNoException(scriptNote, { originEntity }); |  | ||||||
|         } |  | ||||||
|         else { |  | ||||||
|             log.error(`Target note ${relation.value} of atttribute ${relation.attributeId} has not been found.`); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam