mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix delete note function just work one time, closes #1101
This commit is contained in:
		| @@ -1,13 +1,11 @@ | ||||
| import utils from '../services/utils.js'; | ||||
| import Mutex from "../services/mutex.js"; | ||||
|  | ||||
| /** | ||||
|  * Abstract class for all components in the Trilium's frontend. | ||||
|  * | ||||
|  * Contains also event implementation with following properties: | ||||
|  * - event / command distribution is synchronous which among others mean that events are well ordered - event | ||||
|  *   which was sent out first will also be processed first by the component since it was added to the mutex queue | ||||
|  *   as the first one | ||||
|  *   which was sent out first will also be processed first by the component | ||||
|  * - execution of the event / command is asynchronous - each component executes the event on its own without regard for | ||||
|  *   other components. | ||||
|  * - although the execution is async, we are collecting all the promises and therefore it is possible to wait until the | ||||
| @@ -19,7 +17,6 @@ export default class Component { | ||||
|         /** @type Component[] */ | ||||
|         this.children = []; | ||||
|         this.initialized = Promise.resolve(); | ||||
|         this.mutex = new Mutex(); | ||||
|     } | ||||
|  | ||||
|     setParent(parent) { | ||||
| @@ -79,22 +76,8 @@ export default class Component { | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
|         let release; | ||||
|         await fun.call(this, data); | ||||
|  | ||||
|         try { | ||||
|             if (this.mutex.isLocked()) { | ||||
|                 console.debug("Mutex locked for", this.constructor.name); | ||||
|             } | ||||
|  | ||||
|             release = await this.mutex.acquire(); | ||||
|  | ||||
|             await fun.call(this, data); | ||||
|  | ||||
|             return true; | ||||
|         } finally { | ||||
|             if (release) { | ||||
|                 release(); | ||||
|             } | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user