mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	chore(prettier): fix all files
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| import utils from '../services/utils.js'; | ||||
| import { CommandMappings, CommandNames } from './app_context.js'; | ||||
| import utils from "../services/utils.js"; | ||||
| import { CommandMappings, CommandNames } from "./app_context.js"; | ||||
|  | ||||
| /** | ||||
|  * Abstract class for all components in the Trilium's frontend. | ||||
| @@ -28,7 +28,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> { | ||||
|  | ||||
|     get sanitizedClassName() { | ||||
|         // webpack mangles names and sometimes uses unsafe characters | ||||
|         return this.constructor.name.replace(/[^A-Z0-9]/ig, "_"); | ||||
|         return this.constructor.name.replace(/[^A-Z0-9]/gi, "_"); | ||||
|     } | ||||
|  | ||||
|     setParent(parent: TypedComponent<any>) { | ||||
| @@ -48,18 +48,13 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> { | ||||
|  | ||||
|     handleEvent(name: string, data: unknown): Promise<unknown> | null { | ||||
|         try { | ||||
|             const callMethodPromise = this.initialized | ||||
|                 ? this.initialized.then(() => this.callMethod((this as any)[`${name}Event`], data)) | ||||
|                 : this.callMethod((this as any)[`${name}Event`], data); | ||||
|             const callMethodPromise = this.initialized ? this.initialized.then(() => this.callMethod((this as any)[`${name}Event`], data)) : this.callMethod((this as any)[`${name}Event`], data); | ||||
|  | ||||
|             const childrenPromise = this.handleEventInChildren(name, data); | ||||
|  | ||||
|             // don't create promises if not needed (optimization) | ||||
|             return callMethodPromise && childrenPromise | ||||
|                 ? Promise.all([callMethodPromise, childrenPromise]) | ||||
|                 : (callMethodPromise || childrenPromise); | ||||
|         } | ||||
|         catch (e: any) { | ||||
|             return callMethodPromise && childrenPromise ? Promise.all([callMethodPromise, childrenPromise]) : callMethodPromise || childrenPromise; | ||||
|         } catch (e: any) { | ||||
|             console.error(`Handling of event '${name}' failed in ${this.constructor.name} with error ${e.message} ${e.stack}`); | ||||
|  | ||||
|             return null; | ||||
| @@ -101,7 +96,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> { | ||||
|     } | ||||
|  | ||||
|     callMethod(fun: (arg: unknown) => Promise<unknown>, data: unknown) { | ||||
|         if (typeof fun !== 'function') { | ||||
|         if (typeof fun !== "function") { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @@ -111,7 +106,8 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> { | ||||
|  | ||||
|         const took = Date.now() - startTime; | ||||
|  | ||||
|         if (glob.isDev && took > 20) { // measuring only sync handlers | ||||
|         if (glob.isDev && took > 20) { | ||||
|             // measuring only sync handlers | ||||
|             console.log(`Call to ${fun.name} in ${this.componentId} took ${took}ms`); | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user